Re: [boost] Futures (was: Re: [compute] Some remarks)
Concerning std::futures and promises, my thought is wrapping an immutable state in a task, nither future or promise, but with elements of both. Creating a mutex from an asm lock cmpxchg wrapped in c ( available most platforms ) to a shared_ptr gives you a copyable mutex. Not that it matters, but if the state manager ensures a swap every time the arguments are updated, and the state has a ref count destructor, a value storage, function/lambda/member func/functor storage, the effect is an immutable state. once the args are set nothing can change but the execute function or function brackets, a flag in the state ensures that the func will only execute once ( all flags set by single asm instruction xchg, wrapped in c ). this task , or promise if you like, is now copyable, and doesn't require an allocator as the internal state is set by setting the arguments and the state ptr and can be created then. Every time the task/ promise gets copied the shell only exists to point to the state. Having a generic function that wraps any func call in a std::function
participants (1)
-
Antonio Colino