PollableEvent.h 860 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #ifndef PollableEvent_h__
  7. #define PollableEvent_h__
  8. #include "mozilla/Mutex.h"
  9. namespace mozilla {
  10. namespace net {
  11. // class must be called locked
  12. class PollableEvent
  13. {
  14. public:
  15. PollableEvent();
  16. ~PollableEvent();
  17. // Signal/Clear return false only if they fail
  18. bool Signal();
  19. bool Clear();
  20. bool Valid() { return mWriteFD && mReadFD; }
  21. PRFileDesc *PollableFD() { return mReadFD; }
  22. private:
  23. PRFileDesc *mWriteFD;
  24. PRFileDesc *mReadFD;
  25. bool mSignaled;
  26. };
  27. } // namespace net
  28. } // namespace mozilla
  29. #endif