rename: SplitEvent => MulticastEvent #10989

"Multicast" is perhaps a more conventional name for the concept.
"One-shot" is the conventional name for how the event is (currently)
scheduled.
This commit is contained in:
Justin M. Keyes 2019-09-11 15:39:23 -07:00 committed by GitHub
parent 7652904f79
commit b78be5bd08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 12 deletions

View File

@ -82,7 +82,7 @@ typedef struct {
Event event;
bool fired;
int refcount;
} SplitEvent;
} MulticastEvent; ///< Event present on multiple queues.
#ifdef INCLUDE_GENERATED_DECLARATIONS
@ -253,25 +253,25 @@ static MultiQueueItem *multiqueue_node_data(QUEUE *q)
return QUEUE_DATA(q, MultiQueueItem, node);
}
/// Allow an event to be processed by multiple child queues to the main queue
/// Multicasts a one-shot event to multiple queues.
///
/// The handler will be fired once by the _first_ queue that processes the
/// The handler will be invoked once by the _first_ queue that consumes the
/// event. Later processing will do nothing (just memory cleanup).
///
/// @param ev the event
/// @param num number of queues that the split event will be put on
/// @return an Event that is safe to put onto `num` queues
Event event_split(Event ev, int num)
/// @param ev Event
/// @param num Number of queues that the event will be put on
/// @return Event that is safe to put onto `num` queues
Event event_create_oneshot(Event ev, int num)
{
SplitEvent *data = xmalloc(sizeof(*data));
MulticastEvent *data = xmalloc(sizeof(*data));
data->event = ev;
data->fired = false;
data->refcount = num;
return event_create(split_event, 1, data);
return event_create(multiqueue_oneshot_event, 1, data);
}
static void split_event(void ** argv)
static void multiqueue_oneshot_event(void **argv)
{
SplitEvent *data = argv[0];
MulticastEvent *data = argv[0];
if (!data->fired) {
data->fired = true;
if (data->event.handler) {

View File

@ -358,7 +358,8 @@ static void handle_request(Channel *channel, msgpack_object *request)
} else {
bool is_resize = handler.fn == handle_nvim_ui_try_resize;
if (is_resize) {
Event ev = event_split(event_create(request_event, 1, evdata), 2);
Event ev = event_create_oneshot(event_create(request_event, 1, evdata),
2);
multiqueue_put_event(channel->events, ev);
multiqueue_put_event(resize_events, ev);
} else {