Suppose I have a .thrift spec similar to the following:

service Slow
{
  void slowOperation(),
  void stopEverything(),
}

When my application launches, my code will establish a connection with the 
server, and hold on to that connection for the lifetime of the app.  When 
a user launches a dialog box from this application, I want to call 
slowOperation().  If the user hits "Cancel" on the dialog, I want to run 
stopEverything().  stopEverything should cause slowOperation to stop what 
it is doing and complete.

I have several problems with this setup right now.  First, the 
codegenerated SlowClient class isn't thread safe.  If multiple threads try 
to access it at the same time, bad things will happen.  Second, as far as 
I can tell, the existing servers only process messages on one thread per 
connection.  That means that even if I managed to send a stopEverything() 
call while a slowOperation() was in progress, the server wouldn't process 
that message until the slowOperation was complete.

Does the C++ library / compiler currently have anything that can satisfy 
this requirement?  I'm looking at some of the COB / Continuation OBject 
stuff, but it doesn't look like it makes the SlowClient thread safe (but 
maybe the AsyncChannel is supposed to be safe instead?).  It also looks 
like there isn't an easy way to get this behavior for any given transport.

I'm fine adding support for this kind of use case, but I want to make sure 
that nothing already exists that I've overlooked before I go down that 
path.

Reply via email to