@@ -92,29 +92,24 @@ class NotifiableTask {
92
92
93
93
/* *
94
94
* @brief Register an event with the event base associated with this
95
- notifiable task.
95
+ * notifiable task.
96
96
*
97
97
* After registration, the event firing will result in the callback registered
98
- executing on
99
- * the thread this task is running on. Certain events has the same life cycle
100
- as the
101
- * task itself, in which case it is safe to ignore the return value and have
102
- these events
103
- * be freed on destruction of the task. However, if this is not the case, the
104
- caller will
105
- * need to save the return value and manually unregister the event with the
106
- task.
107
- *
108
- * @see UnregisterEvent()
98
+ * executing on the thread this task is running on. Certain events has the
99
+ * same life cycle as the task itself, in which case it is safe to ignore the
100
+ * return value and have these events be freed on destruction of the task.
101
+ * However, if this is not the case, the caller will need to save the return
102
+ * value and manually unregister the event with the task.
103
+ * @see UnregisterEvent().
109
104
*
110
105
* @param fd the file descriptor or signal to be monitored, or -1. (if manual
111
- or time-based)
106
+ * or time-based)
112
107
* @param flags desired events to monitor: bitfield of EV_READ, EV_WRITE,
113
- EV_SIGNAL, EV_PERSIST, EV_ET.
108
+ * EV_SIGNAL, EV_PERSIST, EV_ET.
114
109
* @param callback callback function to be invoked when the event happens
115
110
* @param arg an argument to be passed to the callback function
116
111
* @param timeout the maximum amount of time to wait for an event, defaults to
117
- null which will wait forever
112
+ * null which will wait forever
118
113
* @return pointer to the allocated event.
119
114
*/
120
115
struct event *RegisterEvent (int fd, short flags, event_callback_fn callback,
@@ -176,7 +171,9 @@ class NotifiableTask {
176
171
}
177
172
178
173
// TODO(tianyu): The original network code seems to do this as an
179
- // optimization. I am leaving this out until we get numbers
174
+ // optimization. Specifically it avoids new memory allocation by reusing
175
+ // an existing event. I am leaving this out until we get numbers.
176
+
180
177
// void UpdateEvent(struct event *event, int fd, short flags,
181
178
// event_callback_fn callback, void *arg,
182
179
// const struct timeval *timeout = nullptr) {
0 commit comments