issues surrounding manipulation of CA contexts
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Fix Released
|
Wishlist
|
Jeff Hill |
Bug Description
These requests originate from Ben Franksen:
As far as I can see after studying the CA Client Library documentation,
it is currently not possible to detach (un-attach) a context from a
task without destroying the context.
OTOH, I also gather from the docs that ca_attach_context fails if the
thread already has a context attached (return value is not ECA_SUCCESS
but ECA_ISATTACHED). This makes re-attaching a different context to a
thread impossible without destroying the context, which may not be what
the user wants, because there may be other threads attached to that
context that should continue to run.
What do you think about adding some
void ca_context_detach()
which set the thread's internal (hidden) context to null without
destroying the context (so other threads are not affected).
A client thread could then perform a sequence like
- use ca_current_context
- save the returned context
- detach the old context
- attach a new context
- some time later re-attach the original (saved) context.
This would be a *very* helpful tool for library writers who want to give
users a more idiot proof API.
On a related note, it would be useful if a variant of ca_context_destroy
existed, that gets the context as parameter, instead of destroying the
current context. An application could then keep track of all active
contexts and destroy them when they are no longer used This could be
done by some independent thread. Of course one could fake this by first
attaching to the context and then calling the existing
ca_context_destroy but this seems a little awkward to do.
And while we're at it, maybe some kind of warning should be added to the
docs, that calling ca_context_destroy has a global effect on *all*
threads attached to the current context.
Original Mantis Bug: mantis-161
http://
From Andrei Liyua:
If I am not mistaken there are not couple features in current CA
function interface.
I can suppose that when you came to multithread CA you added
get_current_context and attach functions. But there is not similar
mechanism for ca_context_destoy.
So I open first thread, create CA context, create first CA
channel. Then I open second thread, attach to current CA context, create
second CA channel. ... Then I decide to close first CA channel and
close context (???!!!). What is behavior CA library? I suppose second CA
channel will be closed without normal procedure of closing second
channel + its monitor?
But I don't like to close second channel and CA context! Then I
should check is that channel latest? I couldn't find suitable function
in CA function API. Maybe get_current_context has something. But it is
very deep.
I have once way - hold tracks of my CA channels (minimum is
global counter). Usually it could be done. But if program is mixture of
different libraries and each library comes to CA library then it becomes
impossible.