ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/CommonLibs/ConditionalSemaphore/conditionalsemaphore.cpp
Revision: 1096
Committed: Sat Dec 30 14:40:33 2017 UTC (7 years, 9 months ago) by s10k
Content type: text/x-c++src
File size: 1800 byte(s)
Log Message:
Added zlib, quazip, basicxmlsyntaxhighlighter, conditionalsemaphore and linenumberdisplay libraries. zlib and quazip are pre-compiled, but you can compile them yourself, just delete the dll files (or equivalent binary files to your OS)

File Contents

# Content
1 /**
2 * Copyright (C) 2017 Fábio Bento (random-guy)
3 *
4 * This library is distributed under the MIT License. See notice at the end
5 * of this file.
6 *
7 */
8
9 #include "conditionalsemaphore.h"
10
11 namespace Cosemaphore{
12
13 ConditionalSemaphore::ConditionalSemaphore():
14 internalCounter(0)
15 {
16
17 }
18
19 void ConditionalSemaphore::SetCondition()
20 {
21 this->internalCounter++;
22 }
23
24 void ConditionalSemaphore::UnsetCondition()
25 {
26 this->internalCounter--;
27
28 if(this->internalCounter < 0){
29 throw std::runtime_error("ConditionalSemaphore UnsetCondition called more times than SetCondition.");
30 }
31 }
32
33 bool ConditionalSemaphore::ConditionIsSet()
34 {
35 return this->internalCounter > 0;
36 }
37
38 }
39
40 /**
41 * Copyright (c) 2017
42 *
43 * Permission is hereby granted, free of charge, to any person
44 * obtaining a copy of this software and associated documentation
45 * files (the "Software"), to deal in the Software without
46 * restriction, including without limitation the rights to use,
47 * copy, modify, merge, publish, distribute, sublicense, and/or sell
48 * copies of the Software, and to permit persons to whom the
49 * Software is furnished to do so, subject to the following
50 * conditions:
51 *
52 * The above copyright notice and this permission notice shall be
53 * included in all copies or substantial portions of the Software.
54 *
55 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
56 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
57 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
58 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
59 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
60 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
61 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
62 * OTHER DEALINGS IN THE SOFTWARE.
63 */