From 0f0bdb190b8586ef7ac20fcefffe641e44eb15b9 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 11 Apr 2011 21:44:16 +0300 Subject: server/red_channel: introduce pipes functions Introduce functions to add (via producer method) the same item to multiple pipes, all for the same channel. Note: Right now there is only a single channel, but the next patches will do the per-channel breakdown to channel and channel_client before actually introducing a ring in RedChannel, this makes it easier to make smaller changes - the channel->rcc link will exist until removed in the ring introducing patch. --- server/red_channel.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'server/red_channel.h') diff --git a/server/red_channel.h b/server/red_channel.h index 09a613ae..f11565b6 100644 --- a/server/red_channel.h +++ b/server/red_channel.h @@ -270,6 +270,16 @@ void red_channel_client_set_message_serial(RedChannelClient *channel, uint64_t); void red_channel_client_begin_send_message(RedChannelClient *rcc); void red_channel_pipe_item_init(RedChannel *channel, PipeItem *item, int type); + +// TODO: add back the channel_pipe_add functionality - by adding reference counting +// to the PipeItem. + +// helper to push a new item to all channels +typedef PipeItem *(*new_pipe_item_t)(RedChannelClient *rcc, void *data, int num); +void red_channel_pipes_new_add_push(RedChannel *channel, new_pipe_item_t creator, void *data); +void red_channel_pipes_new_add(RedChannel *channel, new_pipe_item_t creator, void *data); +void red_channel_pipes_new_add_tail(RedChannel *channel, new_pipe_item_t creator, void *data); + void red_channel_client_pipe_add_push(RedChannelClient *rcc, PipeItem *item); void red_channel_client_pipe_add(RedChannelClient *rcc, PipeItem *item); void red_channel_client_pipe_add_after(RedChannelClient *rcc, PipeItem *item, PipeItem *pos); @@ -358,10 +368,10 @@ RedClient *red_channel_client_get_client(RedChannelClient *rcc); SpiceDataHeader *red_channel_client_get_header(RedChannelClient *rcc); /* apply given function to all connected clients */ -typedef void (*channel_client_visitor)(RedChannelClient *rcc); -typedef void (*channel_client_visitor_data)(RedChannelClient *rcc, void *data); -void red_channel_apply_clients(RedChannel *channel, channel_client_visitor v); -void red_channel_apply_clients_data(RedChannel *channel, channel_client_visitor_data v, void *data); +typedef void (*channel_client_callback)(RedChannelClient *rcc); +typedef void (*channel_client_callback_data)(RedChannelClient *rcc, void *data); +void red_channel_apply_clients(RedChannel *channel, channel_client_callback v); +void red_channel_apply_clients_data(RedChannel *channel, channel_client_callback_data v, void *data); struct RedClient { RingItem link; -- cgit