As far as I know waiting on core.sync.Mutex totally blocks a fiber and its worker thread. This is not good, because blocking the worker thread starves or even fully blocks (in single threaded application) other fibers.
Which version of mutex I should using for vibe.core.sync.TaskCondition? I need synchronization only between fibers. But different fibers can be executed by different threads, isn't it? Is it safe to use vibe.core.sync.TaskMutex in this case?
On Fri, 03 May 2013 10:11:02 GMT, Jack Applegame wrote:
As far as I know waiting on core.sync.Mutex totally blocks a fiber and its worker thread. This is not good, because blocking the worker thread starves or even fully blocks (in single threaded application) other fibers.
Which version of mutex I should using for vibe.core.sync.TaskCondition? I need synchronization only between fibers. But different fibers can be executed by different threads, isn't it? Is it safe to use vibe.core.sync.TaskMutex in this case?
TaskMutex
is thread-safe since the last one or two releases and is the recommended way. However, if no I/O or other blocking operations are done while the mutex is locked, you can also safely use a normal Mutex
without hampering event processing. Mutex
has a slight performance advantage in the case of actual contention, but usually this should not be relevant.