On Fri, 2017-03-31 at 20:57 +0200, Daniel Pocock wrote: > > Hi all, > > I came across a discussion about on_sendable[1] only being called > once. > This is what I had observed creating my own application. Usually, > the > first time on_sendable is called, my application doesn't have any > messages to send (there is a data structure in RAM, populated from > another thread) to the on_sendable method just returns without doing > anything and the container never calls it again. > > To work around that, I just let the other thread call the > proton::sender::send() method directly whenever it has a message. Is > that a valid solution, or should the proton::sender::send() method > only > be called in the same thread as the container?
> Could anybody annotate the API docs to indicate which methods are > considered thread safe? Yes: C++ API is developing and the docs need work. I've put a snapshot with some quick pointers at https://alanconway.github.io/index.html - you've probably read the C++ doc already, the C doc is a more succinct description but from a C API point of view. > If it is not wise to call proton::sender::send() from other threads, > how > do I tell the container thread to call on_sendable() from time to > time > to check if there are new messages to be sent? Not wise. To influence a connection from another thread (including from a handler for a *different* connection) you should use event_loop::inject(), there is an example mt_broker that shows this. This area is in need of better doc and possibly improved API, so I'd greatly appreciate your comments on the state of the doc as it is and how to improve it. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
