7 Jan
2014
7 Jan
'14
6:41 p.m.
2014/1/7 Antony Polukhin
Thanks, already trying them. What will happen on fiber::mutex.lock() call if all the fibers on current thread are suspended? Will the mutex call `this_thread::yield()`?
yes. btw, you could take a look at unit-test test_mutex_mt.cpp
Another implementation question: Why there are so many atomics in fiber_base? Looks like fiber is usually used in a single thread, and in situations when fiber is moved from one thread to another memory barrier would be sufficient.
yes, synchronization is done via atomics. In a single threaded env the lib wouldn't require atomics because all fibers running in on thread. A multithread env requires an memory barrier - boost.fiber uses a spinlock which yields a fiber if already locked.