Skip to content

Instantly share code, notes, and snippets.

@yuri-tikhomirov
yuri-tikhomirov / mutex.h
Last active May 27, 2016 16:51 — forked from ytsutano/mutex.h
Simple mutex wrapper class
//
// From https://gist.github.com/ytsutano/4140432 by Yutaka Tsutano
// Modified by Yuri Tikhomirov
// (https://gist.github.com/yuri-tikhomirov/a81343dfd0eeaa4cc80a32aa095a2f5d)
//
// Refactored to support CRITICAL_SECTION usage on Windows,
// also made calls to lock() / try_lock() / unlock() inline.
//
// Performance tests:
// http://preshing.com/20111124/always-use-a-lightweight-mutex/