So what is the preferred solution for my use case?
I will need to push the coorrdination on the stack as this is the only
way for other modules on the thread to find it.
Pop seems to be a bad idea because of the problem of maybe getting a
different coordination.
So if I know my code is only called once on this thread I should be able
to use a simple thread local:
ThreadLocal<Coordination> coordination;
In my interceptor before the user code:
coordination.set(coordinator.begin());
In my interceptor after the user code:
coordination.get().end();
If the code can be called more than once per thread I would need to use
a Stack.
Does that make sense?
Christian
On 03.08.2015 22:00, BJ Hargrave wrote:
In that code snippet, the call to gc() is stand in for other code
which could trigger a gc. And it is also possible that this other code
alters the coordination stack (fails the coordination; coordination
times out; ...), so the pop() call may not return the coordination
began in the first line.
So one really does need to keep the began coordination in a local
variable to ensure you are attempting to end the same coordination you
began. That is, the code snippet is broken in multiple ways.
--
BJ Hargrave
Senior Technical Staff Member, IBM // office: +1 386 848 1781
OSGi Fellow and CTO of the OSGi Alliance // mobile: +1 386 848 3788
hargr...@us.ibm.com
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
http://www.talend.com
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev