[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] Proposal for libevent-2 to provide functions to hide event structure details
- To: libevent-users@xxxxxxxxxxxxx
- Subject: Re: [Libevent-users] Proposal for libevent-2 to provide functions to hide event structure details
- From: Nick Mathewson <nickm@xxxxxxxxxxxxx>
- Date: Sat, 16 Jan 2010 00:49:02 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Sat, 16 Jan 2010 00:49:16 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=6ITUXPaqNbauPxzgFvokHWcbVmRXXJf6o598ma18PM0=; b=vykKD8Aony+D7dkhLZZZ80G4uE4hEG2CaMgoyRZTow+Hub23WuOjud7AJ9oZhALZl4 jFUa3DVEAe8Mg6jIukE0FOPaSunM6UJ9ccUzj4AgpwvcfjCQAa19sJyuCtD3jd2mDo5L 0oVvg2+yUMjiSDGG/f2QB1cA2s25j4VdwXjr0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=o6oyCSIVP4U0tefSa10A3ITXTsLgwdAG0U5+Y11EubBMSyVrRt5pdlV4LiXs9hOIX0 XHmhrnaXap7EAFEyTMYlvDL+Ht+JRtlre4szyTv6ud3TkGOsG+lQWrIm4HRHz5nDysnG 7WuHgytWM7O+jD8egYRoHH0vMIBDMz58qMSww=
- In-reply-to: <201001151148.10457.ppisa4lists@xxxxxxxxxx>
- References: <201001151148.10457.ppisa4lists@xxxxxxxxxx>
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
On Fri, Jan 15, 2010 at 5:48 AM, Pavel Pisa <ppisa4lists@xxxxxxxxxx> wrote:
> Niels and others, # try 4 hopefully correct now and freehaven.net online
>
> please, consider addition of functions to allow access more fields
> of struct event a way ensuring compatibility with future libevent version.
> The list of possible functions prototypes follow. Implementation is attached
> at the end of e-mail.
>
> int event_assign_fd(struct event *ev, evutil_socket_t fd, short events);
> int event_assign_callback(struct event *ev, void (*callback)(evutil_socket_t,
> short, void *), void *arg);
> void *event_get_callback_arg(struct event *ev);
> int event_assign_persist(struct event *ev, int persist);
> size_t event_struct_size(void);
I think event_struct_size() is a fine idea. Most programs won't need
it, but the ones that do will be glad to have it.
I also agree that there should be functions to get every feature of an
event that can be set using event_assign(). Fetching the callback arg
(and the callback, and maybe the event flags) is a missing element of
our current feature set. Maybe the right choice is an
'event_get_assignment' that yields (via assigning to pointers passed
as arguments) everything that was passed to event_assign/event_new:
void event_get_assignment(const struct event *ev, struct event_base
*base_out,
evutil_socket_t *fd_out, short *events_out, void
(**callback_out)(evutil_socket_t, short, void *),
void **callback_arg_out);
Individual convenience functions for individual arguments might be
good too. This is a proliferation of functions, but not a crazy one.
I don't see the rationale behind event_assign_fd() and
event_assign_callback(), though. It seems to me that, given a
non-added event, you could just use event_assign() to reassign all the
fields if you wanted it to refer to a different callback or fd. If
you want to see what some of the old fields were, you could use the
appropriate accessor functions to see what they used to be.
> The rationale:
> - hide event structure implementation/layout. Application using these
> functions
> instead of direct access can keep compatibility with future libevent
> versions.
> To achieve this separation, functions can not be implemented outside of
> libevent.so
Agreed.
> - the function event_get_callback_arg allows read stored callback argument
> without need of its duplication in additional field of some other
> structures
> - the functions event_assign_fd, event_assign_callback and
> event_assign_persist
> allows to allocate event for use with known base in advance and fill FD
> and monitored events later. This can be interresting for RT applications,
> where malloc should not be part of code executed in critical code paths for
> example.
I think that using event_get_assignment [as proposed above] and
event_assign would above two goals.
> - the event_struct_size functions allows to check for incompatible event size
> between libevent version used for program compilation and runtime used
> version.
Yes. This should go in.
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.