Minetest 5.10.0-dev
 
Loading...
Searching...
No Matches
event.h
Go to the documentation of this file.
1/*
2This file is a part of the JThread package, which contains some object-
3oriented thread wrappers for different thread implementations.
4
5Copyright (c) 2000-2006 Jori Liesenborgs (jori.liesenborgs@gmail.com)
6
7Permission is hereby granted, free of charge, to any person obtaining a
8copy of this software and associated documentation files (the "Software"),
9to deal in the Software without restriction, including without limitation
10the rights to use, copy, modify, merge, publish, distribute, sublicense,
11and/or sell copies of the Software, and to permit persons to whom the
12Software is furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in
15all copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23DEALINGS IN THE SOFTWARE.
24*/
25
26#pragma once
27
28#include <condition_variable>
29
36class Event
37{
38public:
39 void wait();
40 void signal();
41
42private:
43 std::condition_variable cv;
44 std::mutex mutex;
45 bool notified = false;
46};
A syncronization primitive that will wake up one waiting thread when signaled.
Definition event.h:37
void wait()
Definition event.cpp:29
void signal()
Definition event.cpp:39
bool notified
Definition event.h:45
std::condition_variable cv
Definition event.h:43
std::mutex mutex
Definition event.h:44