MutexImplWin32.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
21 //----------------------------------------------------------------------
22 
23 #include "icl_core_thread/Common.h"
25 
26 namespace icl_core {
27 namespace thread {
28 
30 {
31  m_mutex = ::CreateMutex(NULL, false, NULL);
32 }
33 
35 {
36  if (m_mutex != 0)
37  {
38  ::CloseHandle(m_mutex);
39  }
40 }
41 
43 {
44  return ::WaitForSingleObject(m_mutex, INFINITE) == WAIT_OBJECT_0;
45 }
46 
48 {
49  return lock(impl::getRelativeTimeout(timeout));
50 }
51 
53 {
54  return ::WaitForSingleObject(m_mutex, DWORD(timeout.toMSec())) == WAIT_OBJECT_0;
55 }
56 
58 {
59  return ::WaitForSingleObject(m_mutex, 0) == WAIT_OBJECT_0;
60 }
61 
63 {
64  ::ReleaseMutex(m_mutex);
65 }
66 
67 }
68 }
Represents absolute times.
Definition: TimeStamp.h:61
Contains icl_core::thread::MutexImplWin32.
int64_t toMSec() const
May result in an overflow if seconds are too large.
Definition: TimeSpan.cpp:163
Contains icl_core::thread::tMutex.
const TimeSpan timeout(1, 0)
Repesents absolute times.
Definition: TimeSpan.h:46
TimeSpan getRelativeTimeout(const TimeStamp &timeout_absolute)
Definition: Common.h:46


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58