blob: 637bfefb4e851ad4105e0b22db39a902a346205b [file] [log] [blame]
Mike J. Chen033e42b2011-08-15 11:26:02 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __PIPE_EVENT_H__
18#define __PIPE_EVENT_H__
19
20namespace android {
21
22class PipeEvent {
23 public:
24 PipeEvent();
25 ~PipeEvent();
26
27 bool initCheck() const {
28 return ((pipe_[0] >= 0) && (pipe_[1] >= 0));
29 }
30
31 int getWakeupHandle() const { return pipe_[0]; }
32
33 // block until the event fires; returns true if the event fired and false if
34 // the wait timed out. Timeout is expressed in milliseconds; negative
35 // values mean wait forever.
36 bool wait(int timeout = -1);
37
38 void clearPendingEvents();
39 void setEvent();
40
41 private:
42 int pipe_[2];
43};
44
45} // namespace android
46
47#endif // __PIPE_EVENT_H__