On Sun, 01 May 2016 10:39:20 GMT, chmike wrote:
Unfortunately the code is not correct because the global variable is declared as shared. And this implies that the class must be synchronized.
As a consequence this is not compatible with vibe.d fibers since we should use vibe.d friendly fibers. The variable increment was a dummy operation for example. In practice it could be an operation doing blocking calls.
What you can do is to use setSameMutex
to change the object monitor to a TaskMutex
. You can then either use a synchronized class, or use the lock
idiom (basically casts away shared
in a safe way). setSameMutex
is in object.d and I think the argument order must be setSameMutex(object, task_mutex);
but I'm not sure.