Matthias Vallentin wrote:
I've written something quite simple that is also able to do 2), semantics are Asio-like,
reference_counter m_counter; ios.post( m_counter.wrap( task1 ) ); ios.post( m_counter.wrap( task2 ) ); ios.post( m_counter.wrap( task3 ) ); m_counter.async_wait( all_complete_handler );
How does the task structure look like here? It looks like the tasks execute concurrently and increment a counter on start/finish - atomically, as you say. What I mean with structure are for example hierarchical (e.g., tree-like) groupings of tasks.
Right. Tasks are wrapped/bound handlers (like in Asio). Hierarchical stuff would look like reference_counter m_counter_1; reference_counter m_counter_2; ios.post( m_counter_1.wrap( task1 ) ); ios.post( m_counter_1.wrap( task2 ) ); ios.post( m_counter_2.wrap( task3 ) ); m_counter_1.async_wait( m_counter_2.wrap( task4 ) ); m_counter_2.async_wait( task5 ); Execution dependencies and order will be 1) task1, task2, task3 2) task4 3) task5
I haven't looked at it in detail, but Oliver Kowalke's task and fiber implementation in the Boost vault look like a good starting point. From the documentation, it seems there is some support for structuring tasks via sub-tasks. The libraries support atomic operations via Boost.Atomic.
I haven't look at those in detail, yet. For atomic stuff, I just borrowed the atomic counter from boost/detail. Cheers, Rutger