icl_core_thread/SemaphoreImplWin32.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 #include "SemaphoreImplWin32.h"
23 
24 #include "Common.h"
25 
26 namespace icl_core {
27 namespace thread {
28 
30  : m_semaphore(0)
31 {
32  m_semaphore = CreateSemaphore(NULL, LONG(initial_value), LONG_MAX, NULL);
33 }
34 
36 {
37  CloseHandle(m_semaphore);
38 }
39 
41 {
42  ReleaseSemaphore(m_semaphore, 1, NULL);
43 }
44 
46 {
47  DWORD res = WaitForSingleObject(m_semaphore, 0);
48  return res == WAIT_OBJECT_0;
49 }
50 
52 {
53  DWORD res = WaitForSingleObject(m_semaphore, INFINITE);
54  return res == WAIT_OBJECT_0;
55 }
56 
58 {
59  DWORD res = WaitForSingleObject(m_semaphore, DWORD(timeout.toMSec()));
60  return res == WAIT_OBJECT_0;
61 }
62 
64 {
65  return wait(impl::getRelativeTimeout(timeout));
66 }
67 
68 }
69 }
Represents absolute times.
Definition: TimeStamp.h:61
int64_t toMSec() const
May result in an overflow if seconds are too large.
Definition: TimeSpan.cpp:163
Contains icl_core::thread::SemaphoreImplWin32.
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