Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef PollableEvent_h__
8 : #define PollableEvent_h__
9 :
10 : #include "mozilla/Mutex.h"
11 :
12 : namespace mozilla {
13 : namespace net {
14 :
15 : // class must be called locked
16 : class PollableEvent
17 : {
18 : public:
19 : PollableEvent();
20 : ~PollableEvent();
21 :
22 : // Signal/Clear return false only if they fail
23 : bool Signal();
24 : bool Clear();
25 3 : bool Valid() { return mWriteFD && mReadFD; }
26 :
27 3 : PRFileDesc *PollableFD() { return mReadFD; }
28 :
29 : private:
30 : PRFileDesc *mWriteFD;
31 : PRFileDesc *mReadFD;
32 : bool mSignaled;
33 : };
34 :
35 : } // namespace net
36 : } // namespace mozilla
37 :
38 : #endif
|