Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / system / SystemWakeEvent.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 /**
19  *    @file
20  *      This file declares the abstraction of system wake event used for
21  *      resuming task from select system call.
22  */
23
24 #pragma once
25
26 // Include configuration headers
27 #include <system/SystemConfig.h>
28
29 #include <system/SystemError.h>
30
31 namespace chip {
32 namespace System {
33
34 using ::chip::System::Error;
35
36 class SystemWakeEvent
37 {
38 public:
39     Error Open();  /**< Initialize the pipeline */
40     Error Close(); /**< Close both ends of the pipeline. */
41
42 #if CHIP_SYSTEM_CONFIG_USE_POSIX_PIPE
43     int GetNotifFD() const { return mFDs[FD_READ]; }
44 #else
45     int GetNotifFD() const { return mFD; }
46 #endif
47
48     Error Notify();  /**< Set the event. */
49     Error Confirm(); /**< Clear the event. */
50
51 private:
52 #if CHIP_SYSTEM_CONFIG_USE_POSIX_PIPE
53     enum
54     {
55         FD_READ  = 0,
56         FD_WRITE = 1
57     };
58
59     int mFDs[2];
60 #else
61     int mFD;
62 #endif
63 };
64
65 } // namespace System
66 } // namespace chip