2222#include < memory>
2323#include < unordered_map>
2424
25- extern " C" {
26- #include " ae/ae.h"
27- }
25+ struct aeEventLoop ;
2826
2927namespace plasma {
3028
29+ // The constants below are defined using hardcoded values taken from ae.h so
30+ // that ae.h does not need to be included in this file.
31+
3132// / Constant specifying that the timer is done and it will be removed.
32- constexpr int kEventLoopTimerDone = AE_NOMORE ;
33+ constexpr int kEventLoopTimerDone = -1 ; // AE_NOMORE
34+
35+ // / A successful status.
36+ constexpr int kEventLoopOk = 0 ; // AE_OK
3337
3438// / Read event on the file descriptor.
35- constexpr int kEventLoopRead = AE_READABLE ;
39+ constexpr int kEventLoopRead = 1 ; // AE_READABLE
3640
3741// / Write event on the file descriptor.
38- constexpr int kEventLoopWrite = AE_WRITABLE ;
42+ constexpr int kEventLoopWrite = 2 ; // AE_WRITABLE
3943
4044typedef long long TimerID; // NOLINT
4145
@@ -57,29 +61,29 @@ class EventLoop {
5761
5862 // / Add a new file event handler to the event loop.
5963 // /
60- // / @ param fd The file descriptor we are listening to.
61- // / @ param events The flags for events we are listening to (read or write).
62- // / @ param callback The callback that will be called when the event happens.
63- // / @ return Returns true if the event handler was added successfully.
64+ // / \ param fd The file descriptor we are listening to.
65+ // / \ param events The flags for events we are listening to (read or write).
66+ // / \ param callback The callback that will be called when the event happens.
67+ // / \ return Returns true if the event handler was added successfully.
6468 bool AddFileEvent (int fd, int events, const FileCallback& callback);
6569
6670 // / Remove a file event handler from the event loop.
6771 // /
68- // / @ param fd The file descriptor of the event handler.
72+ // / \ param fd The file descriptor of the event handler.
6973 void RemoveFileEvent (int fd);
7074
7175 // / Register a handler that will be called after a time slice of
72- // / "timeout" milliseconds.
76+ // / "timeout" milliseconds.
7377 // /
74- // / @ param timeout The timeout in milliseconds.
75- // / @ param callback The callback for the timeout.
76- // / @ return The ID of the newly created timer.
78+ // / \ param timeout The timeout in milliseconds.
79+ // / \ param callback The callback for the timeout.
80+ // / \ return The ID of the newly created timer.
7781 int64_t AddTimer (int64_t timeout, const TimerCallback& callback);
7882
7983 // / Remove a timer handler from the event loop.
8084 // /
81- // / @ param timer_id The ID of the timer that is to be removed.
82- // / @ return The ae.c error code. TODO(pcm): needs to be standardized
85+ // / \ param timer_id The ID of the timer that is to be removed.
86+ // / \ return The ae.c error code. TODO(pcm): needs to be standardized
8387 int RemoveTimer (int64_t timer_id);
8488
8589 // / \brief Run the event loop.
0 commit comments