ipc/chromium/src/third_party/libevent/changelist-internal.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/third_party/libevent/changelist-internal.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,101 @@
     1.4 +/*
     1.5 + * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson
     1.6 + *
     1.7 + * Redistribution and use in source and binary forms, with or without
     1.8 + * modification, are permitted provided that the following conditions
     1.9 + * are met:
    1.10 + * 1. Redistributions of source code must retain the above copyright
    1.11 + *    notice, this list of conditions and the following disclaimer.
    1.12 + * 2. Redistributions in binary form must reproduce the above copyright
    1.13 + *    notice, this list of conditions and the following disclaimer in the
    1.14 + *    documentation and/or other materials provided with the distribution.
    1.15 + * 3. The name of the author may not be used to endorse or promote products
    1.16 + *    derived from this software without specific prior written permission.
    1.17 + *
    1.18 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    1.19 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    1.20 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    1.21 + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    1.22 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    1.23 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.24 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    1.25 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.26 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    1.27 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.28 + */
    1.29 +#ifndef _CHANGELIST_H_
    1.30 +#define _CHANGELIST_H_
    1.31 +
    1.32 +/*
    1.33 +  A "changelist" is a list of all the fd status changes that should be made
    1.34 +  between calls to the backend's dispatch function.  There are a few reasons
    1.35 +  that a backend would want to queue changes like this rather than processing
    1.36 +  them immediately.
    1.37 +
    1.38 +    1) Sometimes applications will add and delete the same event more than
    1.39 +       once between calls to dispatch.  Processing these changes immediately
    1.40 +       is needless, and potentially expensive (especially if we're on a system
    1.41 +       that makes one syscall per changed event).
    1.42 +
    1.43 +    2) Sometimes we can coalesce multiple changes on the same fd into a single
    1.44 +       syscall if we know about them in advance.  For example, epoll can do an
    1.45 +       add and a delete at the same time, but only if we have found out about
    1.46 +       both of them before we tell epoll.
    1.47 +
    1.48 +    3) Sometimes adding an event that we immediately delete can cause
    1.49 +       unintended consequences: in kqueue, this makes pending events get
    1.50 +       reported spuriously.
    1.51 + */
    1.52 +
    1.53 +#include "event2/util.h"
    1.54 +
    1.55 +/** Represents a */
    1.56 +struct event_change {
    1.57 +	/** The fd or signal whose events are to be changed */
    1.58 +	evutil_socket_t fd;
    1.59 +	/* The events that were enabled on the fd before any of these changes
    1.60 +	   were made.  May include EV_READ or EV_WRITE. */
    1.61 +	short old_events;
    1.62 +
    1.63 +	/* The changes that we want to make in reading and writing on this fd.
    1.64 +	 * If this is a signal, then read_change has EV_CHANGE_SIGNAL set,
    1.65 +	 * and write_change is unused. */
    1.66 +	ev_uint8_t read_change;
    1.67 +	ev_uint8_t write_change;
    1.68 +};
    1.69 +
    1.70 +/* Flags for read_change and write_change. */
    1.71 +
    1.72 +/* If set, add the event. */
    1.73 +#define EV_CHANGE_ADD     0x01
    1.74 +/* If set, delete the event.  Exclusive with EV_CHANGE_ADD */
    1.75 +#define EV_CHANGE_DEL     0x02
    1.76 +/* If set, this event refers a signal, not an fd. */
    1.77 +#define EV_CHANGE_SIGNAL  EV_SIGNAL
    1.78 +/* Set for persistent events.  Currently not used. */
    1.79 +#define EV_CHANGE_PERSIST EV_PERSIST
    1.80 +/* Set for adding edge-triggered events. */
    1.81 +#define EV_CHANGE_ET      EV_ET
    1.82 +
    1.83 +/* The value of fdinfo_size that a backend should use if it is letting
    1.84 + * changelist handle its add and delete functions. */
    1.85 +#define EVENT_CHANGELIST_FDINFO_SIZE sizeof(int)
    1.86 +
    1.87 +/** Set up the data fields in a changelist. */
    1.88 +void event_changelist_init(struct event_changelist *changelist);
    1.89 +/** Remove every change in the changelist, and make corresponding changes
    1.90 + * in the event maps in the base.  This function is generally used right
    1.91 + * after making all the changes in the changelist. */
    1.92 +void event_changelist_remove_all(struct event_changelist *changelist,
    1.93 +    struct event_base *base);
    1.94 +/** Free all memory held in a changelist. */
    1.95 +void event_changelist_freemem(struct event_changelist *changelist);
    1.96 +
    1.97 +/** Implementation of eventop_add that queues the event in a changelist. */
    1.98 +int event_changelist_add(struct event_base *base, evutil_socket_t fd, short old, short events,
    1.99 +    void *p);
   1.100 +/** Implementation of eventop_del that queues the event in a changelist. */
   1.101 +int event_changelist_del(struct event_base *base, evutil_socket_t fd, short old, short events,
   1.102 +    void *p);
   1.103 +
   1.104 +#endif

mercurial