diff --git a/src/ca/CAref.html b/src/ca/CAref.html index 93006b6e0..231b3be07 100644 --- a/src/ca/CAref.html +++ b/src/ca/CAref.html @@ -2,7 +2,7 @@ "http://www.w3.org/TR/html4/loose.dtd"> - + EPICS R3.14 Channel Access Reference Manual @@ -169,7 +169,8 @@ height="31" width="88">

  • ca_create_channel
  • ca_create_subscription
  • ca_current_context
  • -
  • ca_dump_dbr()
  • +
  • ca_dump_dbr
  • +
  • ca_detach_context
  • ca_element_count
  • ca_field_type
  • ca_flush_io
  • @@ -2290,7 +2291,7 @@ int ca_context_create ( enum ca_preemptive_callback_select SELECT );Description

    This function, or ca_attach_context(), -should be called once for each thread prior to making any of the other +should be called once from each thread prior to making any of the other Channel Access calls. If one of the above is not called before making other CA calls then a non-preemptive context is created by default, and future attempts to create a preemptive context for the current threads will fail.

    @@ -2333,8 +2334,12 @@ void ca_context_destroy();

    Description

    -

    Shut down a channel access client context and free any resources -allocated.

    +

    Shut down the calling thread's channel access client context and free any +resources allocated. Detach the calling thread from any CA client context.

    + +

    Be advised that any user created threads that might have attached +themselves to the CA context must of course stop using it prior to its being +destroyed.

    On many OS that execute programs in a process based environment the resources used by the client library such as sockets and allocated memory are @@ -3881,12 +3886,18 @@ returned.

    ca_attach_context()

    +

    ca_detach_context()

    + +

    ca_context_create()

    + +

    ca_context_destroy()

    +

    ca_attach_context()

    int ca_attach_context (struct ca_client_context *CONTEXT);

    Description

    -

    Become a member of the specified CA context. If +

    The calling thread becomes a member of the specified CA context. If ca_disable_preemptive_callback is specified when ca_context_create() is called (or if ca_task_initialize() is called) then additional threads are not allowed to join the CA context because @@ -3906,10 +3917,37 @@ preemptively from more than one thread.

    ECA_NOTTHREADED - the specified context is non-preemptive and therefore does not allow other threads to join

    +

    ECA_ISATTACHED - the current thread is already attached to a CA context

    +

    See Also

    ca_current_context()

    +

    ca_detach_context()

    + +

    ca_context_create()

    + +

    ca_context_destroy()

    + +

    ca_detach_context()

    +
    void ca_detach_context();
    + +

    Description

    + +

    Detach from any CA context currently attached to the calling thread. This +does not cleanup or shutdown any currently attached CA context (for +that use ca_context_destroy).

    + +

    See Also

    + +

    ca_current_context()

    + +

    ca_attach_context()

    + +

    ca_context_create()

    + +

    ca_context_destroy()

    +

    ca_dump_dbr()

    void ca_dump_dbr ( chtype TYPE, unsigned COUNT, const diff --git a/src/ca/access.cpp b/src/ca/access.cpp index 29aa4f344..b440a08b5 100644 --- a/src/ca/access.cpp +++ b/src/ca/access.cpp @@ -738,6 +738,13 @@ int epicsShareAPI ca_attach_context ( struct ca_client_context * pCtx ) return ECA_NORMAL; } +void epicsShareAPI ca_detach_context () +{ + if ( caClientContextId ) { + epicsThreadPrivateSet ( caClientContextId, 0 ); + } +} + int epicsShareAPI ca_preemtive_callback_is_enabled () { ca_client_context *pcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );