Hi
Hi there,
I'm starting to use Continuations in my code... I'm presuming that they're
all nicely working. ;-)
thanks for experimenting and hope they'll work nicely for you.
I noticed the following code on Sergey's blog:
Continuation c = provider.getContinuation();
synchronized (c) {
...
}
Does the continuation really have to be synchronised or does the API
guarantee the object as being thread safe? Given the domain I would have
thought that the API and underlying implementations should be able to cope
with reentrancy.
We have a support for HTTP [1] and JMS [2] continuations.
In case of HTTP we delegate to a Jetty Continuation handler, and I guess the only place in [1] where we need to synchronize is
setObject() and suspend() such that we can ensure a current Message is associated with a continuation instance, while preserving the
previously set user object if any. Thus, we might be abe to drop the requirement on the external synchronization when HTTP is the
underlying transport and do some protection internally. I've also CC-ed to Guillaume, I think I saw synchronized blocks around Jetty
continuations in SMX4 too so may be Guillaume can explain us few more things...
JMS one [2] is a light weight piece of code and at a time I found it would be a bit awkward to ensure it's properly synchronized
given that it deals with various states. If you look at suspend() for ex, then you'll see the synchronization block around the
instance, but it will only work reliably if tthe client code follows the external synchronization rule.
Thus, at the moment, it's the client code which is in charge, as it may need to deal with either HTTP or JMS primitives with various
requirements toward the synchronization. That said, I'd be happy to discuss how we can drop this requirement...
Cheers, Sergey
[1]
https://svn.apache.org/repos/asf/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
[2]
https://svn.apache.org/repos/asf/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/continuations/JMSContinuation.java
Kind regards,
Christopher
--
View this message in context:
http://www.nabble.com/Continuations-and-thread-safety-tp22920013p22920013.html
Sent from the cxf-user mailing list archive at Nabble.com.