MutexImplWin32.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 //----------------------------------------------------------------------
00008 //----------------------------------------------------------------------
00009 
00010 #include "icl_core_thread/Common.h"
00011 #include "icl_core_thread/MutexImplWin32.h"
00012 
00013 namespace icl_core {
00014 namespace thread {
00015 
00016 MutexImplWin32::MutexImplWin32()
00017 {
00018   m_mutex = ::CreateMutex(NULL, false, NULL);
00019 }
00020 
00021 MutexImplWin32::~MutexImplWin32()
00022 {
00023   if (m_mutex != 0)
00024   {
00025     ::CloseHandle(m_mutex);
00026   }
00027 }
00028 
00029 bool MutexImplWin32::lock()
00030 {
00031   return ::WaitForSingleObject(m_mutex, INFINITE) == WAIT_OBJECT_0;
00032 }
00033 
00034 bool MutexImplWin32::lock(const TimeStamp& timeout)
00035 {
00036   return lock(impl::getRelativeTimeout(timeout));
00037 }
00038 
00039 bool MutexImplWin32::lock(const TimeSpan& timeout)
00040 {
00041   return ::WaitForSingleObject(m_mutex, DWORD(timeout.toMSec())) == WAIT_OBJECT_0;
00042 }
00043 
00044 bool MutexImplWin32::tryLock()
00045 {
00046   return ::WaitForSingleObject(m_mutex, 0) == WAIT_OBJECT_0;
00047 }
00048 
00049 void MutexImplWin32::unlock()
00050 {
00051   ::ReleaseMutex(m_mutex);
00052 }
00053 
00054 }
00055 }


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19