comparison osx/include/kj/async-unix.h @ 147:45360b968bf4

Cap'n Proto v0.6 + build for OSX
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 22 May 2017 10:01:37 +0100
parents 41e769c91eca
children
comparison
equal deleted inserted replaced
146:206f0eb279b8 147:45360b968bf4
20 // THE SOFTWARE. 20 // THE SOFTWARE.
21 21
22 #ifndef KJ_ASYNC_UNIX_H_ 22 #ifndef KJ_ASYNC_UNIX_H_
23 #define KJ_ASYNC_UNIX_H_ 23 #define KJ_ASYNC_UNIX_H_
24 24
25 #if _WIN32
26 #error "This file is Unix-specific. On Windows, include async-win32.h instead."
27 #endif
28
25 #if defined(__GNUC__) && !KJ_HEADER_WARNINGS 29 #if defined(__GNUC__) && !KJ_HEADER_WARNINGS
26 #pragma GCC system_header 30 #pragma GCC system_header
27 #endif 31 #endif
28 32
29 #include "async.h" 33 #include "async.h"
91 static void setReservedSignal(int signum); 95 static void setReservedSignal(int signum);
92 // Sets the signal number which `UnixEventPort` reserves for internal use. If your application 96 // Sets the signal number which `UnixEventPort` reserves for internal use. If your application
93 // needs to use SIGUSR1, call this at startup (before any calls to `captureSignal()` and before 97 // needs to use SIGUSR1, call this at startup (before any calls to `captureSignal()` and before
94 // constructing an `UnixEventPort`) to offer a different signal. 98 // constructing an `UnixEventPort`) to offer a different signal.
95 99
96 TimePoint steadyTime() { return frozenSteadyTime; } 100 Timer& getTimer() { return timerImpl; }
97 Promise<void> atSteadyTime(TimePoint time);
98 101
99 // implements EventPort ------------------------------------------------------ 102 // implements EventPort ------------------------------------------------------
100 bool wait() override; 103 bool wait() override;
101 bool poll() override; 104 bool poll() override;
102 void wake() const override; 105 void wake() const override;
104 private: 107 private:
105 struct TimerSet; // Defined in source file to avoid STL include. 108 struct TimerSet; // Defined in source file to avoid STL include.
106 class TimerPromiseAdapter; 109 class TimerPromiseAdapter;
107 class SignalPromiseAdapter; 110 class SignalPromiseAdapter;
108 111
109 Own<TimerSet> timers; 112 TimerImpl timerImpl;
110 TimePoint frozenSteadyTime;
111 113
112 SignalPromiseAdapter* signalHead = nullptr; 114 SignalPromiseAdapter* signalHead = nullptr;
113 SignalPromiseAdapter** signalTail = &signalHead; 115 SignalPromiseAdapter** signalTail = &signalHead;
114 116
115 TimePoint currentSteadyTime(); 117 TimePoint readClock();
116 void processTimers();
117 void gotSignal(const siginfo_t& siginfo); 118 void gotSignal(const siginfo_t& siginfo);
118 119
119 friend class TimerPromiseAdapter; 120 friend class TimerPromiseAdapter;
120 121
121 #if KJ_USE_EPOLL 122 #if KJ_USE_EPOLL