Is there any implementation of monitor on Windows? I didn't see any win32 API references Monitor.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Windows does not have a monitor implementation of its own. However, Vista introduced Condition Variables and Slim Reader/Writer locks, which can be used together to create a monitor implementation.
回答2:
Yes it does. Windows has monitors and monitor functions: EnterCriticalSection is similar to POSIX pthread_mutex_lock (enters the monitor). LeaveCriticalSection is similar to POSIX pthread_mutex_unlock (leaves monitor).
SleepConditionVariableCS similar to POSIX pthread_cond_wait.
WakeConditionVariable ... POSIX pthread_cond_signal.
WakeAllConditionVariable ... POSIX pthread_cond_broadcast
All these funcions you can find here:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686360(v=vs.85).aspx