Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / tools / android / forwarder2 / pipe_notifier.h
blobaadb26934b01e471a326a8da56db7de10ff4c076
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef TOOLS_ANDROID_FORWARDER2_PIPE_NOTIFIER_H_
6 #define TOOLS_ANDROID_FORWARDER2_PIPE_NOTIFIER_H_
8 #include "base/basictypes.h"
10 namespace forwarder2 {
12 // Helper class used to create a unix pipe that sends notifications to the
13 // |receiver_fd_| file descriptor when called |Notify()|. This should be used
14 // by the main thread to notify other threads that it must exit.
15 // The |receiver_fd_| can be put into a fd_set and used in a select together
16 // with a socket waiting to accept or read.
17 class PipeNotifier {
18 public:
19 PipeNotifier();
20 ~PipeNotifier();
22 bool Notify();
24 int receiver_fd() const { return receiver_fd_; }
26 void Reset();
28 private:
29 int sender_fd_;
30 int receiver_fd_;
32 DISALLOW_COPY_AND_ASSIGN(PipeNotifier);
35 } // namespace forwarder
37 #endif // TOOLS_ANDROID_FORWARDER2_PIPE_NOTIFIER_H_