Doc: Fix broken link
[TortoiseGit.git] / src / AsyncFramework / WaitableEvent.h
bloba2246cb78e38ab105b93ed992fed13055d26c5f2
1 /***************************************************************************
2 * Copyright (C) 2009 by Stefan Fuhrmann *
3 * stefanfuhrmann@alice-dsl.de *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #pragma once
23 namespace async
26 /**
27 * A waitable event that can be signaled only once.
28 * Also, only one waiting thread is allowed.
30 * This is a more lightweight implementation than
31 * \ref CWaitableEvent as the \ref event handle is
32 * only allocated if \ref WaitFor() requires it.
35 class COneShotEvent
37 private:
39 /// OS-specific event object
41 HANDLE event;
42 volatile LONG state;
44 public:
46 /// construction / destruction: manage event handle
48 COneShotEvent();
49 ~COneShotEvent();
51 /// eventing interface
53 void Set();
54 bool Test() const;
55 void WaitFor();
57 /// returns false in case of a timeout
59 bool WaitForEndOrTimeout(DWORD milliSeconds);
62 /**
63 * A waitable event that must be reset manually.
64 * This implementation uses a global pool of event
65 * handles to minimize OS handle creation and destruction
66 * overhead.
69 class CWaitableEvent
71 private:
73 /// OS-specific event object
75 HANDLE event;
77 public:
79 /// construction / destruction: manage event handle
81 CWaitableEvent();
82 ~CWaitableEvent();
84 /// eventing interface
86 void Set();
87 void Reset();
88 bool Test() const;
89 void WaitFor();
91 /// returns false in case of a timeout
93 bool WaitForEndOrTimeout(DWORD milliSeconds);