Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 1 | #ifndef AOS_EVENTS_EVENT_LOOP_H_ |
| 2 | #define AOS_EVENTS_EVENT_LOOP_H_ |
| 3 | |
Brian Silverman | 6a54ff3 | 2020-04-28 16:41:39 -0700 | [diff] [blame] | 4 | #include <sched.h> |
| 5 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 6 | #include <atomic> |
| 7 | #include <string> |
James Kuszmaul | 3ae4226 | 2019-11-08 12:33:41 -0800 | [diff] [blame] | 8 | #include <string_view> |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 9 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 10 | #include "aos/configuration.h" |
| 11 | #include "aos/configuration_generated.h" |
Austin Schuh | 1af273d | 2020-03-07 20:11:34 -0800 | [diff] [blame] | 12 | #include "aos/events/channel_preallocated_allocator.h" |
Austin Schuh | 7d87b67 | 2019-12-01 20:23:49 -0800 | [diff] [blame] | 13 | #include "aos/events/event_loop_event.h" |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 14 | #include "aos/events/event_loop_generated.h" |
| 15 | #include "aos/events/timing_statistics.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 16 | #include "aos/flatbuffers.h" |
Brian Silverman | a1652f3 | 2020-01-29 20:41:44 -0800 | [diff] [blame] | 17 | #include "aos/ipc_lib/data_alignment.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 18 | #include "aos/json_to_flatbuffer.h" |
| 19 | #include "aos/time/time.h" |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 20 | #include "aos/util/phased_loop.h" |
Brian Silverman | 0fc6993 | 2020-01-24 21:54:02 -0800 | [diff] [blame] | 21 | |
| 22 | #include "absl/container/btree_set.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 23 | #include "flatbuffers/flatbuffers.h" |
| 24 | #include "glog/logging.h" |
| 25 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 26 | DECLARE_bool(timing_reports); |
| 27 | DECLARE_int32(timing_report_ms); |
| 28 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 29 | namespace aos { |
| 30 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 31 | class EventLoop; |
| 32 | class WatcherState; |
| 33 | |
Austin Schuh | 6231cc3 | 2019-12-07 13:06:15 -0800 | [diff] [blame] | 34 | // Struct available on Watchers, Fetchers, Timers, and PhasedLoops with context |
| 35 | // about the current message. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 36 | struct Context { |
Austin Schuh | ad15482 | 2019-12-27 15:45:13 -0800 | [diff] [blame] | 37 | // Time that the message was sent on this node, or the timer was triggered. |
| 38 | monotonic_clock::time_point monotonic_event_time; |
| 39 | // Realtime the message was sent on this node. This is set to min_time for |
| 40 | // Timers and PhasedLoops. |
| 41 | realtime_clock::time_point realtime_event_time; |
| 42 | |
| 43 | // For a single-node configuration, these two are identical to *_event_time. |
| 44 | // In a multinode configuration, these are the times that the message was |
| 45 | // sent on the original node. |
| 46 | monotonic_clock::time_point monotonic_remote_time; |
| 47 | realtime_clock::time_point realtime_remote_time; |
| 48 | |
Austin Schuh | 6231cc3 | 2019-12-07 13:06:15 -0800 | [diff] [blame] | 49 | // The rest are only valid for Watchers and Fetchers. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 50 | // Index in the queue. |
| 51 | uint32_t queue_index; |
Austin Schuh | ad15482 | 2019-12-27 15:45:13 -0800 | [diff] [blame] | 52 | // Index into the remote queue. Useful to determine if data was lost. In a |
| 53 | // single-node configuration, this will match queue_index. |
| 54 | uint32_t remote_queue_index; |
| 55 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 56 | // Size of the data sent. |
| 57 | size_t size; |
| 58 | // Pointer to the data. |
| 59 | void *data; |
| 60 | }; |
| 61 | |
| 62 | // Raw version of fetcher. Contains a local variable that the fetcher will |
| 63 | // update. This is used for reflection and as an interface to implement typed |
| 64 | // fetchers. |
| 65 | class RawFetcher { |
| 66 | public: |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 67 | RawFetcher(EventLoop *event_loop, const Channel *channel); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 68 | RawFetcher(const RawFetcher &) = delete; |
| 69 | RawFetcher &operator=(const RawFetcher &) = delete; |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 70 | virtual ~RawFetcher(); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 71 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 72 | // Fetches the next message in the queue without blocking. Returns true if |
| 73 | // there was a new message and we got it. |
| 74 | bool FetchNext(); |
| 75 | |
| 76 | // Fetches the latest message without blocking. |
| 77 | bool Fetch(); |
| 78 | |
| 79 | // Returns the channel this fetcher uses. |
| 80 | const Channel *channel() const { return channel_; } |
| 81 | // Returns the context for the current message. |
| 82 | const Context &context() const { return context_; } |
| 83 | |
| 84 | protected: |
| 85 | EventLoop *event_loop() { return event_loop_; } |
| 86 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 87 | Context context_; |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 88 | |
| 89 | private: |
| 90 | friend class EventLoop; |
| 91 | // Implementation |
| 92 | virtual std::pair<bool, monotonic_clock::time_point> DoFetchNext() = 0; |
| 93 | virtual std::pair<bool, monotonic_clock::time_point> DoFetch() = 0; |
| 94 | |
| 95 | EventLoop *event_loop_; |
Austin Schuh | 54cf95f | 2019-11-29 13:14:18 -0800 | [diff] [blame] | 96 | const Channel *channel_; |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 97 | |
| 98 | internal::RawFetcherTiming timing_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | // Raw version of sender. Sends a block of data. This is used for reflection |
| 102 | // and as a building block to implement typed senders. |
| 103 | class RawSender { |
| 104 | public: |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 105 | RawSender(EventLoop *event_loop, const Channel *channel); |
| 106 | RawSender(const RawSender &) = delete; |
| 107 | RawSender &operator=(const RawSender &) = delete; |
| 108 | |
| 109 | virtual ~RawSender(); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 110 | |
| 111 | // Sends a message without copying it. The users starts by copying up to |
| 112 | // size() bytes into the data backed by data(). They then call Send to send. |
| 113 | // Returns true on a successful send. |
Austin Schuh | ad15482 | 2019-12-27 15:45:13 -0800 | [diff] [blame] | 114 | // If provided, monotonic_remote_time, realtime_remote_time, and |
| 115 | // remote_queue_index are attached to the message and are available in the |
| 116 | // context on the read side. If they are not populated, the read side will |
| 117 | // get the sent times instead. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 118 | virtual void *data() = 0; |
| 119 | virtual size_t size() = 0; |
Austin Schuh | ad15482 | 2019-12-27 15:45:13 -0800 | [diff] [blame] | 120 | bool Send(size_t size, |
| 121 | aos::monotonic_clock::time_point monotonic_remote_time = |
| 122 | aos::monotonic_clock::min_time, |
| 123 | aos::realtime_clock::time_point realtime_remote_time = |
| 124 | aos::realtime_clock::min_time, |
| 125 | uint32_t remote_queue_index = 0xffffffffu); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 126 | |
| 127 | // Sends a single block of data by copying it. |
Austin Schuh | ad15482 | 2019-12-27 15:45:13 -0800 | [diff] [blame] | 128 | // The remote arguments have the same meaning as in Send above. |
| 129 | bool Send(const void *data, size_t size, |
| 130 | aos::monotonic_clock::time_point monotonic_remote_time = |
| 131 | aos::monotonic_clock::min_time, |
| 132 | aos::realtime_clock::time_point realtime_remote_time = |
| 133 | aos::realtime_clock::min_time, |
| 134 | uint32_t remote_queue_index = 0xffffffffu); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 135 | |
Austin Schuh | 54cf95f | 2019-11-29 13:14:18 -0800 | [diff] [blame] | 136 | const Channel *channel() const { return channel_; } |
| 137 | |
Austin Schuh | ad15482 | 2019-12-27 15:45:13 -0800 | [diff] [blame] | 138 | // Returns the time_points that the last message was sent at. |
| 139 | aos::monotonic_clock::time_point monotonic_sent_time() const { |
| 140 | return monotonic_sent_time_; |
| 141 | } |
| 142 | aos::realtime_clock::time_point realtime_sent_time() const { |
| 143 | return realtime_sent_time_; |
| 144 | } |
| 145 | // Returns the queue index that this was sent with. |
| 146 | uint32_t sent_queue_index() const { return sent_queue_index_; } |
| 147 | |
Brian Silverman | a1652f3 | 2020-01-29 20:41:44 -0800 | [diff] [blame] | 148 | // Returns the associated flatbuffers-style allocator. This must be |
| 149 | // deallocated before the message is sent. |
Austin Schuh | 1af273d | 2020-03-07 20:11:34 -0800 | [diff] [blame] | 150 | ChannelPreallocatedAllocator *fbb_allocator() { |
| 151 | fbb_allocator_ = ChannelPreallocatedAllocator( |
| 152 | reinterpret_cast<uint8_t *>(data()), size(), channel()); |
Brian Silverman | a1652f3 | 2020-01-29 20:41:44 -0800 | [diff] [blame] | 153 | return &fbb_allocator_; |
| 154 | } |
| 155 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 156 | protected: |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 157 | EventLoop *event_loop() { return event_loop_; } |
Austin Schuh | 54cf95f | 2019-11-29 13:14:18 -0800 | [diff] [blame] | 158 | |
Austin Schuh | ad15482 | 2019-12-27 15:45:13 -0800 | [diff] [blame] | 159 | aos::monotonic_clock::time_point monotonic_sent_time_ = |
| 160 | aos::monotonic_clock::min_time; |
| 161 | aos::realtime_clock::time_point realtime_sent_time_ = |
| 162 | aos::realtime_clock::min_time; |
| 163 | uint32_t sent_queue_index_ = 0xffffffff; |
| 164 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 165 | private: |
| 166 | friend class EventLoop; |
| 167 | |
Austin Schuh | ad15482 | 2019-12-27 15:45:13 -0800 | [diff] [blame] | 168 | virtual bool DoSend(const void *data, size_t size, |
| 169 | aos::monotonic_clock::time_point monotonic_remote_time, |
| 170 | aos::realtime_clock::time_point realtime_remote_time, |
| 171 | uint32_t remote_queue_index) = 0; |
| 172 | virtual bool DoSend(size_t size, |
| 173 | aos::monotonic_clock::time_point monotonic_remote_time, |
| 174 | aos::realtime_clock::time_point realtime_remote_time, |
| 175 | uint32_t remote_queue_index) = 0; |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 176 | |
| 177 | EventLoop *event_loop_; |
Austin Schuh | 54cf95f | 2019-11-29 13:14:18 -0800 | [diff] [blame] | 178 | const Channel *channel_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 179 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 180 | internal::RawSenderTiming timing_; |
Brian Silverman | a1652f3 | 2020-01-29 20:41:44 -0800 | [diff] [blame] | 181 | |
Austin Schuh | 1af273d | 2020-03-07 20:11:34 -0800 | [diff] [blame] | 182 | ChannelPreallocatedAllocator fbb_allocator_{nullptr, 0, nullptr}; |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 183 | }; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 184 | |
| 185 | // Fetches the newest message from a channel. |
| 186 | // This provides a polling based interface for channels. |
| 187 | template <typename T> |
| 188 | class Fetcher { |
| 189 | public: |
| 190 | Fetcher() {} |
| 191 | |
| 192 | // Fetches the next message. Returns true if it fetched a new message. This |
| 193 | // method will only return messages sent after the Fetcher was created. |
Brian Silverman | a1652f3 | 2020-01-29 20:41:44 -0800 | [diff] [blame] | 194 | bool FetchNext() { |
| 195 | const bool result = fetcher_->FetchNext(); |
| 196 | if (result) { |
| 197 | CheckChannelDataAlignment(fetcher_->context().data, |
| 198 | fetcher_->context().size); |
| 199 | } |
| 200 | return result; |
| 201 | } |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 202 | |
| 203 | // Fetches the most recent message. Returns true if it fetched a new message. |
| 204 | // This will return the latest message regardless of if it was sent before or |
| 205 | // after the fetcher was created. |
Brian Silverman | a1652f3 | 2020-01-29 20:41:44 -0800 | [diff] [blame] | 206 | bool Fetch() { |
| 207 | const bool result = fetcher_->Fetch(); |
| 208 | if (result) { |
| 209 | CheckChannelDataAlignment(fetcher_->context().data, |
| 210 | fetcher_->context().size); |
| 211 | } |
| 212 | return result; |
| 213 | } |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 214 | |
| 215 | // Returns a pointer to the contained flatbuffer, or nullptr if there is no |
| 216 | // available message. |
| 217 | const T *get() const { |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 218 | return fetcher_->context().data != nullptr |
| 219 | ? flatbuffers::GetRoot<T>( |
| 220 | reinterpret_cast<const char *>(fetcher_->context().data)) |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 221 | : nullptr; |
| 222 | } |
| 223 | |
| 224 | // Returns the context holding timestamps and other metadata about the |
| 225 | // message. |
| 226 | const Context &context() const { return fetcher_->context(); } |
| 227 | |
| 228 | const T &operator*() const { return *get(); } |
| 229 | const T *operator->() const { return get(); } |
| 230 | |
| 231 | private: |
| 232 | friend class EventLoop; |
| 233 | Fetcher(::std::unique_ptr<RawFetcher> fetcher) |
| 234 | : fetcher_(::std::move(fetcher)) {} |
| 235 | ::std::unique_ptr<RawFetcher> fetcher_; |
| 236 | }; |
| 237 | |
| 238 | // Sends messages to a channel. |
| 239 | template <typename T> |
| 240 | class Sender { |
| 241 | public: |
| 242 | Sender() {} |
| 243 | |
| 244 | // Represents a single message about to be sent to the queue. |
| 245 | // The lifecycle goes: |
| 246 | // |
| 247 | // Builder builder = sender.MakeBuilder(); |
| 248 | // T::Builder t_builder = builder.MakeBuilder<T>(); |
| 249 | // Populate(&t_builder); |
| 250 | // builder.Send(t_builder.Finish()); |
| 251 | class Builder { |
| 252 | public: |
Austin Schuh | 1af273d | 2020-03-07 20:11:34 -0800 | [diff] [blame] | 253 | Builder(RawSender *sender, ChannelPreallocatedAllocator *allocator) |
Brian Silverman | 9dd793b | 2020-01-31 23:52:21 -0800 | [diff] [blame] | 254 | : fbb_(allocator->size(), allocator), |
| 255 | allocator_(allocator), |
| 256 | sender_(sender) { |
Brian Silverman | a1652f3 | 2020-01-29 20:41:44 -0800 | [diff] [blame] | 257 | CheckChannelDataAlignment(allocator->data(), allocator->size()); |
Austin Schuh | d7b15da | 2020-02-17 15:06:11 -0800 | [diff] [blame] | 258 | fbb_.ForceDefaults(true); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 259 | } |
Brian Silverman | a1652f3 | 2020-01-29 20:41:44 -0800 | [diff] [blame] | 260 | Builder() {} |
| 261 | Builder(const Builder &) = delete; |
| 262 | Builder(Builder &&) = default; |
| 263 | |
| 264 | Builder &operator=(const Builder &) = delete; |
| 265 | Builder &operator=(Builder &&) = default; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 266 | |
| 267 | flatbuffers::FlatBufferBuilder *fbb() { return &fbb_; } |
| 268 | |
| 269 | template <typename T2> |
| 270 | typename T2::Builder MakeBuilder() { |
| 271 | return typename T2::Builder(fbb_); |
| 272 | } |
| 273 | |
| 274 | bool Send(flatbuffers::Offset<T> offset) { |
| 275 | fbb_.Finish(offset); |
Brian Silverman | 9dd793b | 2020-01-31 23:52:21 -0800 | [diff] [blame] | 276 | const bool result = sender_->Send(fbb_.GetSize()); |
| 277 | // Ensure fbb_ knows it shouldn't access the memory any more. |
| 278 | fbb_ = flatbuffers::FlatBufferBuilder(); |
| 279 | return result; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | // CHECKs that this message was sent. |
Brian Silverman | 9dd793b | 2020-01-31 23:52:21 -0800 | [diff] [blame] | 283 | void CheckSent() { |
| 284 | CHECK(!allocator_->is_allocated()) << ": Message was not sent yet"; |
| 285 | } |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 286 | |
| 287 | private: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 288 | flatbuffers::FlatBufferBuilder fbb_; |
Austin Schuh | 1af273d | 2020-03-07 20:11:34 -0800 | [diff] [blame] | 289 | ChannelPreallocatedAllocator *allocator_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 290 | RawSender *sender_; |
| 291 | }; |
| 292 | |
| 293 | // Constructs an above builder. |
Brian Silverman | 9dd793b | 2020-01-31 23:52:21 -0800 | [diff] [blame] | 294 | // |
| 295 | // Only a single one of these may be "alive" for this object at any point in |
| 296 | // time. After calling Send on the result, it is no longer "alive". This means |
| 297 | // that you must manually reset a variable holding the return value (by |
| 298 | // assigning a default-constructed Builder to it) before calling this method |
| 299 | // again to overwrite the value in the variable. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 300 | Builder MakeBuilder(); |
| 301 | |
Austin Schuh | a28cbc3 | 2019-12-27 16:28:04 -0800 | [diff] [blame] | 302 | // Sends a prebuilt flatbuffer. |
| 303 | bool Send(const Flatbuffer<T> &flatbuffer); |
| 304 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 305 | // Returns the name of the underlying queue. |
Austin Schuh | 1e86947 | 2019-12-01 13:36:10 -0800 | [diff] [blame] | 306 | const Channel *channel() const { return sender_->channel(); } |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 307 | |
Brian Silverman | 454bc11 | 2020-03-05 14:21:25 -0800 | [diff] [blame] | 308 | operator bool() { return sender_ ? true : false; } |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 309 | |
Austin Schuh | 7bc5905 | 2020-02-16 23:48:33 -0800 | [diff] [blame] | 310 | // Returns the time_points that the last message was sent at. |
| 311 | aos::monotonic_clock::time_point monotonic_sent_time() const { |
| 312 | return sender_->monotonic_sent_time(); |
| 313 | } |
| 314 | aos::realtime_clock::time_point realtime_sent_time() const { |
| 315 | return sender_->realtime_sent_time(); |
| 316 | } |
| 317 | // Returns the queue index that this was sent with. |
| 318 | uint32_t sent_queue_index() const { return sender_->sent_queue_index(); } |
| 319 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 320 | private: |
| 321 | friend class EventLoop; |
| 322 | Sender(std::unique_ptr<RawSender> sender) : sender_(std::move(sender)) {} |
| 323 | std::unique_ptr<RawSender> sender_; |
| 324 | }; |
| 325 | |
| 326 | // Interface for timers |
| 327 | class TimerHandler { |
| 328 | public: |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 329 | virtual ~TimerHandler(); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 330 | |
| 331 | // Timer should sleep until base, base + offset, base + offset * 2, ... |
| 332 | // If repeat_offset isn't set, the timer only expires once. |
| 333 | virtual void Setup(monotonic_clock::time_point base, |
| 334 | monotonic_clock::duration repeat_offset = |
| 335 | ::aos::monotonic_clock::zero()) = 0; |
| 336 | |
| 337 | // Stop future calls to callback(). |
| 338 | virtual void Disable() = 0; |
Austin Schuh | 1540c2f | 2019-11-29 21:59:29 -0800 | [diff] [blame] | 339 | |
| 340 | // Sets and gets the name of the timer. Set this if you want a descriptive |
| 341 | // name in the timing report. |
| 342 | void set_name(std::string_view name) { name_ = std::string(name); } |
| 343 | const std::string_view name() const { return name_; } |
| 344 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 345 | protected: |
| 346 | TimerHandler(EventLoop *event_loop, std::function<void()> fn); |
| 347 | |
Austin Schuh | cde39fd | 2020-02-22 20:58:24 -0800 | [diff] [blame] | 348 | monotonic_clock::time_point Call( |
| 349 | std::function<monotonic_clock::time_point()> get_time, |
| 350 | monotonic_clock::time_point event_time); |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 351 | |
Austin Schuh | 1540c2f | 2019-11-29 21:59:29 -0800 | [diff] [blame] | 352 | private: |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 353 | friend class EventLoop; |
| 354 | |
| 355 | EventLoop *event_loop_; |
| 356 | // The function to call when Call is called. |
| 357 | std::function<void()> fn_; |
Austin Schuh | 1540c2f | 2019-11-29 21:59:29 -0800 | [diff] [blame] | 358 | std::string name_; |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 359 | |
| 360 | internal::TimerTiming timing_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 361 | }; |
| 362 | |
| 363 | // Interface for phased loops. They are built on timers. |
| 364 | class PhasedLoopHandler { |
| 365 | public: |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 366 | virtual ~PhasedLoopHandler(); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 367 | |
| 368 | // Sets the interval and offset. Any changes to interval and offset only take |
| 369 | // effect when the handler finishes running. |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 370 | void set_interval_and_offset(const monotonic_clock::duration interval, |
| 371 | const monotonic_clock::duration offset) { |
| 372 | phased_loop_.set_interval_and_offset(interval, offset); |
| 373 | } |
Austin Schuh | 1540c2f | 2019-11-29 21:59:29 -0800 | [diff] [blame] | 374 | |
| 375 | // Sets and gets the name of the timer. Set this if you want a descriptive |
| 376 | // name in the timing report. |
| 377 | void set_name(std::string_view name) { name_ = std::string(name); } |
| 378 | const std::string_view name() const { return name_; } |
| 379 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 380 | protected: |
| 381 | void Call(std::function<monotonic_clock::time_point()> get_time, |
| 382 | std::function<void(monotonic_clock::time_point)> schedule); |
| 383 | |
| 384 | PhasedLoopHandler(EventLoop *event_loop, std::function<void(int)> fn, |
| 385 | const monotonic_clock::duration interval, |
| 386 | const monotonic_clock::duration offset); |
| 387 | |
Austin Schuh | 1540c2f | 2019-11-29 21:59:29 -0800 | [diff] [blame] | 388 | private: |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 389 | friend class EventLoop; |
| 390 | |
| 391 | void Reschedule(std::function<void(monotonic_clock::time_point)> schedule, |
| 392 | monotonic_clock::time_point monotonic_now) { |
| 393 | cycles_elapsed_ += phased_loop_.Iterate(monotonic_now); |
| 394 | schedule(phased_loop_.sleep_time()); |
| 395 | } |
| 396 | |
| 397 | virtual void Schedule(monotonic_clock::time_point sleep_time) = 0; |
| 398 | |
| 399 | EventLoop *event_loop_; |
| 400 | std::function<void(int)> fn_; |
Austin Schuh | 1540c2f | 2019-11-29 21:59:29 -0800 | [diff] [blame] | 401 | std::string name_; |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 402 | time::PhasedLoop phased_loop_; |
| 403 | |
| 404 | int cycles_elapsed_ = 0; |
| 405 | |
| 406 | internal::TimerTiming timing_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 407 | }; |
| 408 | |
Brian Silverman | 6a54ff3 | 2020-04-28 16:41:39 -0700 | [diff] [blame] | 409 | inline cpu_set_t MakeCpusetFromCpus(std::initializer_list<int> cpus) { |
| 410 | cpu_set_t result; |
| 411 | CPU_ZERO(&result); |
| 412 | for (int cpu : cpus) { |
| 413 | CPU_SET(cpu, &result); |
| 414 | } |
| 415 | return result; |
| 416 | } |
| 417 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 418 | class EventLoop { |
| 419 | public: |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 420 | EventLoop(const Configuration *configuration); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 421 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 422 | virtual ~EventLoop(); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 423 | |
| 424 | // Current time. |
| 425 | virtual monotonic_clock::time_point monotonic_now() = 0; |
| 426 | virtual realtime_clock::time_point realtime_now() = 0; |
| 427 | |
| 428 | // Note, it is supported to create: |
| 429 | // multiple fetchers, and (one sender or one watcher) per <name, type> |
| 430 | // tuple. |
| 431 | |
| 432 | // Makes a class that will always fetch the most recent value |
| 433 | // sent to the provided channel. |
| 434 | template <typename T> |
James Kuszmaul | 3ae4226 | 2019-11-08 12:33:41 -0800 | [diff] [blame] | 435 | Fetcher<T> MakeFetcher(const std::string_view channel_name) { |
Austin Schuh | bca6cf0 | 2019-12-22 17:28:34 -0800 | [diff] [blame] | 436 | const Channel *channel = |
| 437 | configuration::GetChannel(configuration_, channel_name, |
| 438 | T::GetFullyQualifiedName(), name(), node()); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 439 | CHECK(channel != nullptr) |
| 440 | << ": Channel { \"name\": \"" << channel_name << "\", \"type\": \"" |
| 441 | << T::GetFullyQualifiedName() << "\" } not found in config."; |
| 442 | |
Austin Schuh | ca4828c | 2019-12-28 14:21:35 -0800 | [diff] [blame] | 443 | if (!configuration::ChannelIsReadableOnNode(channel, node())) { |
| 444 | LOG(FATAL) << "Channel { \"name\": \"" << channel_name |
| 445 | << "\", \"type\": \"" << T::GetFullyQualifiedName() |
| 446 | << "\" } is not able to be fetched on this node. Check your " |
| 447 | "configuration."; |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 448 | } |
| 449 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 450 | return Fetcher<T>(MakeRawFetcher(channel)); |
| 451 | } |
| 452 | |
| 453 | // Makes class that allows constructing and sending messages to |
| 454 | // the provided channel. |
| 455 | template <typename T> |
James Kuszmaul | 3ae4226 | 2019-11-08 12:33:41 -0800 | [diff] [blame] | 456 | Sender<T> MakeSender(const std::string_view channel_name) { |
Austin Schuh | bca6cf0 | 2019-12-22 17:28:34 -0800 | [diff] [blame] | 457 | const Channel *channel = |
| 458 | configuration::GetChannel(configuration_, channel_name, |
| 459 | T::GetFullyQualifiedName(), name(), node()); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 460 | CHECK(channel != nullptr) |
| 461 | << ": Channel { \"name\": \"" << channel_name << "\", \"type\": \"" |
Austin Schuh | 28fedcb | 2020-02-08 15:59:58 -0800 | [diff] [blame] | 462 | << T::GetFullyQualifiedName() << "\" } not found in config for " |
| 463 | << name() << "."; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 464 | |
Austin Schuh | ca4828c | 2019-12-28 14:21:35 -0800 | [diff] [blame] | 465 | if (!configuration::ChannelIsSendableOnNode(channel, node())) { |
| 466 | LOG(FATAL) << "Channel { \"name\": \"" << channel_name |
| 467 | << "\", \"type\": \"" << T::GetFullyQualifiedName() |
| 468 | << "\" } is not able to be sent on this node. Check your " |
| 469 | "configuration."; |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 470 | } |
| 471 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 472 | return Sender<T>(MakeRawSender(channel)); |
| 473 | } |
| 474 | |
| 475 | // This will watch messages sent to the provided channel. |
| 476 | // |
Brian Silverman | 454bc11 | 2020-03-05 14:21:25 -0800 | [diff] [blame] | 477 | // w must have a non-polymorphic operator() (aka it can only be called with a |
| 478 | // single set of arguments; no overloading or templates). It must be callable |
| 479 | // with this signature: |
| 480 | // void(const MessageType &); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 481 | // |
Brian Silverman | 454bc11 | 2020-03-05 14:21:25 -0800 | [diff] [blame] | 482 | // Lambdas are a common form for w. A std::function will work too. |
| 483 | // |
| 484 | // Note that bind expressions have polymorphic call operators, so they are not |
| 485 | // allowed. |
| 486 | // |
| 487 | // We template Watch as a whole instead of using std::function<void(const T |
| 488 | // &)> to allow deducing MessageType from lambdas and other things which are |
| 489 | // implicitly convertible to std::function, but not actually std::function |
| 490 | // instantiations. Template deduction guides might allow solving this |
| 491 | // differently in newer versions of C++, but those have their own corner |
| 492 | // cases. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 493 | template <typename Watch> |
Brian Silverman | 454bc11 | 2020-03-05 14:21:25 -0800 | [diff] [blame] | 494 | void MakeWatcher(const std::string_view channel_name, Watch &&w); |
| 495 | |
| 496 | // Like MakeWatcher, but doesn't have access to the message data. This may be |
| 497 | // implemented to use less resources than an equivalent MakeWatcher. |
| 498 | // |
Brian Silverman | 6b8a3c3 | 2020-03-06 11:26:14 -0800 | [diff] [blame] | 499 | // The function will still have access to context(), although that will have |
| 500 | // its data field set to nullptr. |
Brian Silverman | 454bc11 | 2020-03-05 14:21:25 -0800 | [diff] [blame] | 501 | template <typename MessageType> |
| 502 | void MakeNoArgWatcher(const std::string_view channel_name, |
| 503 | std::function<void()> w); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 504 | |
| 505 | // The passed in function will be called when the event loop starts. |
| 506 | // Use this to run code once the thread goes into "real-time-mode", |
| 507 | virtual void OnRun(::std::function<void()> on_run) = 0; |
| 508 | |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 509 | // Gets the name of the event loop. This is the application name. |
James Kuszmaul | 3ae4226 | 2019-11-08 12:33:41 -0800 | [diff] [blame] | 510 | virtual const std::string_view name() const = 0; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 511 | |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 512 | // Returns the node that this event loop is running on. Returns nullptr if we |
| 513 | // are running in single-node mode. |
| 514 | virtual const Node *node() const = 0; |
| 515 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 516 | // Creates a timer that executes callback when the timer expires |
| 517 | // Returns a TimerHandle for configuration of the timer |
| 518 | virtual TimerHandler *AddTimer(::std::function<void()> callback) = 0; |
| 519 | |
| 520 | // Creates a timer that executes callback periodically at the specified |
| 521 | // interval and offset. Returns a PhasedLoopHandler for interacting with the |
| 522 | // timer. |
| 523 | virtual PhasedLoopHandler *AddPhasedLoop( |
| 524 | ::std::function<void(int)> callback, |
| 525 | const monotonic_clock::duration interval, |
| 526 | const monotonic_clock::duration offset = ::std::chrono::seconds(0)) = 0; |
| 527 | |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 528 | // TODO(austin): OnExit for cleanup. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 529 | |
| 530 | // Threadsafe. |
| 531 | bool is_running() const { return is_running_.load(); } |
| 532 | |
| 533 | // Sets the scheduler priority to run the event loop at. This may not be |
| 534 | // called after we go into "real-time-mode". |
| 535 | virtual void SetRuntimeRealtimePriority(int priority) = 0; |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 536 | virtual int priority() const = 0; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 537 | |
Brian Silverman | 6a54ff3 | 2020-04-28 16:41:39 -0700 | [diff] [blame] | 538 | // Sets the scheduler affinity to run the event loop with. This may only be |
| 539 | // called before Run(). |
| 540 | virtual void SetRuntimeAffinity(const cpu_set_t &cpuset) = 0; |
| 541 | |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 542 | // Fetches new messages from the provided channel (path, type). |
| 543 | // |
| 544 | // Note: this channel must be a member of the exact configuration object this |
| 545 | // was built with. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 546 | virtual std::unique_ptr<RawFetcher> MakeRawFetcher( |
| 547 | const Channel *channel) = 0; |
| 548 | |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 549 | // Watches channel (name, type) for new messages. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 550 | virtual void MakeRawWatcher( |
| 551 | const Channel *channel, |
| 552 | std::function<void(const Context &context, const void *message)> |
| 553 | watcher) = 0; |
| 554 | |
Brian Silverman | 454bc11 | 2020-03-05 14:21:25 -0800 | [diff] [blame] | 555 | // Watches channel (name, type) for new messages, without needing to extract |
| 556 | // the message contents. Default implementation simply re-uses MakeRawWatcher. |
| 557 | virtual void MakeRawNoArgWatcher( |
| 558 | const Channel *channel, |
| 559 | std::function<void(const Context &context)> watcher) { |
| 560 | MakeRawWatcher(channel, [watcher](const Context &context, const void *) { |
Brian Silverman | 6b8a3c3 | 2020-03-06 11:26:14 -0800 | [diff] [blame] | 561 | Context new_context = context; |
| 562 | new_context.data = nullptr; |
| 563 | watcher(new_context); |
Brian Silverman | 454bc11 | 2020-03-05 14:21:25 -0800 | [diff] [blame] | 564 | }); |
| 565 | } |
| 566 | |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 567 | // Creates a raw sender for the provided channel. This is used for reflection |
| 568 | // based sending. |
| 569 | // Note: this ignores any node constraints. Ignore at your own peril. |
| 570 | virtual std::unique_ptr<RawSender> MakeRawSender(const Channel *channel) = 0; |
| 571 | |
Austin Schuh | 6231cc3 | 2019-12-07 13:06:15 -0800 | [diff] [blame] | 572 | // Returns the context for the current callback. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 573 | const Context &context() const { return context_; } |
| 574 | |
| 575 | // Returns the configuration that this event loop was built with. |
| 576 | const Configuration *configuration() const { return configuration_; } |
| 577 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 578 | // Prevents the event loop from sending a timing report. |
| 579 | void SkipTimingReport() { skip_timing_report_ = true; } |
| 580 | |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 581 | // Prevents AOS_LOG being sent to message on /aos |
| 582 | void SkipAosLog() { skip_logger_ = true; } |
| 583 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 584 | protected: |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 585 | // Sets the name of the event loop. This is the application name. |
| 586 | virtual void set_name(const std::string_view name) = 0; |
| 587 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 588 | void set_is_running(bool value) { is_running_.store(value); } |
| 589 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 590 | // Validates that channel exists inside configuration_ and finds its index. |
| 591 | int ChannelIndex(const Channel *channel); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 592 | |
Brian Silverman | 5120afb | 2020-01-31 17:44:35 -0800 | [diff] [blame] | 593 | // Returns the state for the watcher on the corresponding channel. This |
| 594 | // watcher must exist before calling this. |
| 595 | WatcherState *GetWatcherState(const Channel *channel); |
| 596 | |
| 597 | // Returns a Sender's protected RawSender |
| 598 | template <typename T> |
| 599 | static RawSender *GetRawSender(aos::Sender<T> *sender) { |
| 600 | return sender->sender_.get(); |
| 601 | } |
| 602 | |
Austin Schuh | 6231cc3 | 2019-12-07 13:06:15 -0800 | [diff] [blame] | 603 | // Context available for watchers, timers, and phased loops. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 604 | Context context_; |
| 605 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 606 | friend class RawSender; |
| 607 | friend class TimerHandler; |
| 608 | friend class RawFetcher; |
| 609 | friend class PhasedLoopHandler; |
| 610 | friend class WatcherState; |
| 611 | |
| 612 | // Methods used to implement timing reports. |
| 613 | void NewSender(RawSender *sender); |
| 614 | void DeleteSender(RawSender *sender); |
| 615 | TimerHandler *NewTimer(std::unique_ptr<TimerHandler> timer); |
| 616 | PhasedLoopHandler *NewPhasedLoop( |
| 617 | std::unique_ptr<PhasedLoopHandler> phased_loop); |
| 618 | void NewFetcher(RawFetcher *fetcher); |
| 619 | void DeleteFetcher(RawFetcher *fetcher); |
| 620 | WatcherState *NewWatcher(std::unique_ptr<WatcherState> watcher); |
| 621 | |
Brian Silverman | 0fc6993 | 2020-01-24 21:54:02 -0800 | [diff] [blame] | 622 | // Tracks that we have a (single) watcher on the given channel. |
| 623 | void TakeWatcher(const Channel *channel); |
| 624 | // Tracks that we have at least one sender on the given channel. |
| 625 | void TakeSender(const Channel *channel); |
| 626 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 627 | std::vector<RawSender *> senders_; |
Austin Schuh | 7d87b67 | 2019-12-01 20:23:49 -0800 | [diff] [blame] | 628 | std::vector<RawFetcher *> fetchers_; |
| 629 | |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 630 | std::vector<std::unique_ptr<TimerHandler>> timers_; |
| 631 | std::vector<std::unique_ptr<PhasedLoopHandler>> phased_loops_; |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 632 | std::vector<std::unique_ptr<WatcherState>> watchers_; |
| 633 | |
| 634 | void SendTimingReport(); |
| 635 | void UpdateTimingReport(); |
| 636 | void MaybeScheduleTimingReports(); |
| 637 | |
| 638 | std::unique_ptr<RawSender> timing_report_sender_; |
| 639 | |
Austin Schuh | 7d87b67 | 2019-12-01 20:23:49 -0800 | [diff] [blame] | 640 | // Tracks which event sources (timers and watchers) have data, and which |
| 641 | // don't. Added events may not change their event_time(). |
| 642 | // TODO(austin): Test case 1: timer triggers at t1, handler takes until after |
| 643 | // t2 to run, t2 should then be picked up without a context switch. |
| 644 | void AddEvent(EventLoopEvent *event); |
| 645 | void RemoveEvent(EventLoopEvent *event); |
| 646 | size_t EventCount() const { return events_.size(); } |
| 647 | EventLoopEvent *PopEvent(); |
| 648 | EventLoopEvent *PeekEvent() { return events_.front(); } |
| 649 | void ReserveEvents(); |
| 650 | |
| 651 | std::vector<EventLoopEvent *> events_; |
| 652 | |
Tyler Chatow | 67ddb03 | 2020-01-12 14:30:04 -0800 | [diff] [blame] | 653 | // If true, don't send AOS_LOG to /aos |
| 654 | bool skip_logger_ = false; |
| 655 | |
Austin Schuh | de8a8ff | 2019-11-30 15:25:36 -0800 | [diff] [blame] | 656 | private: |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 657 | virtual pid_t GetTid() = 0; |
| 658 | |
| 659 | FlatbufferDetachedBuffer<timing::Report> timing_report_; |
| 660 | |
Austin Schuh | de8a8ff | 2019-11-30 15:25:36 -0800 | [diff] [blame] | 661 | ::std::atomic<bool> is_running_{false}; |
| 662 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 663 | const Configuration *configuration_; |
Austin Schuh | 39788ff | 2019-12-01 18:22:57 -0800 | [diff] [blame] | 664 | |
| 665 | // If true, don't send out timing reports. |
| 666 | bool skip_timing_report_ = false; |
Brian Silverman | 0fc6993 | 2020-01-24 21:54:02 -0800 | [diff] [blame] | 667 | |
| 668 | absl::btree_set<const Channel *> taken_watchers_, taken_senders_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 669 | }; |
| 670 | |
| 671 | } // namespace aos |
| 672 | |
| 673 | #include "aos/events/event_loop_tmpl.h" |
| 674 | |
| 675 | #endif // AOS_EVENTS_EVENT_LOOP_H |