On Thu, 2016-03-17 at 17:09 -0400, Alan Conway wrote:
> The proton::container is single threaded, once you call run() you
> can't
> interact with it from other threads.
> 
> I'd like to propose a "function injection" interface. I think the
> analogous thing could be done for all the languages. The Go binding
> already has this mechanism.
> 
> The idea is to provide a thread safe call that injects a simple
> "callable" object with no parameters and no return value.
> 
> In  C++11 this is easy to do: 
> 
> class container {
>     void inject(std::function<void()>)
> }
> 
> Semantics: calling inject() will queue the injected function to be
> called as soon as is reasonable in the run() thread.

This is definitely the interface I was thinking of.

I'm not clear exactly how the context carrying through the event queue
works though to be honest.

> ... (lots of useful examples)

> In C++03 we can support the functionality in a clunky way that is not
> very efficient or easy to use, but works:

It's actually exactly as efficient in principle as it does the same
thing without the decent syntax!

My objection to this is that I don't think this precise proposal would
allow you to use a boost::function<> and tbh that's the only way I
would do this sort of thing in '03.

But if as Justin says we can just support injected functions where
std::function exists then this is moot.

Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to