Remove retrieval of old value in set() calls.
The old value can be retrieved with one of the get() calls if necessary, so it seems to redundant to also be able to retrieve it via set().
This commit is contained in:
parent
f301a0dcea
commit
f8f6e4aa3b
|
@ -47,11 +47,9 @@ int lwevent_get_autodestroy(const struct lwevent* ev)
|
||||||
* perform the call if the new events match the current events. If `old_events' is not null, stores
|
* perform the call if the new events match the current events. If `old_events' is not null, stores
|
||||||
* the existing events before changing. Returns -1 if epoll_ctl fails.
|
* the existing events before changing. Returns -1 if epoll_ctl fails.
|
||||||
*/
|
*/
|
||||||
int lwevent_set_events(struct lwevent* ev, int events, int* old_events)
|
int lwevent_set_events(struct lwevent* ev, int events)
|
||||||
{
|
{
|
||||||
if(old_events) *old_events = ev->events;
|
|
||||||
if(events == ev->events) return 0; /* don't call epoll_ctl() if no change */
|
if(events == ev->events) return 0; /* don't call epoll_ctl() if no change */
|
||||||
|
|
||||||
return _lwevent_activate(EPOLL_CTL_MOD, ev);
|
return _lwevent_activate(EPOLL_CTL_MOD, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,28 +58,23 @@ int lwevent_set_events(struct lwevent* ev, int events, int* old_events)
|
||||||
/* lwevent_set_*()
|
/* lwevent_set_*()
|
||||||
* Changes attributes associated with `ev', possibly storing the old value.
|
* Changes attributes associated with `ev', possibly storing the old value.
|
||||||
*/
|
*/
|
||||||
void lwevent_set_callback(struct lwevent* ev, lwevent_callback callback,
|
void lwevent_set_callback(struct lwevent* ev, lwevent_callback callback)
|
||||||
lwevent_callback* old_callback)
|
|
||||||
{
|
{
|
||||||
if(old_callback) *old_callback = ev->callback;
|
|
||||||
ev->callback = callback;
|
ev->callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lwevent_set_user(struct lwevent* ev, void* user, void** old_user)
|
void lwevent_set_user(struct lwevent* ev, void* user)
|
||||||
{
|
{
|
||||||
if(old_user) *old_user = ev->user;
|
|
||||||
ev->user = user;
|
ev->user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lwevent_set_dtor(struct lwevent* ev, lwevent_dtor dtor, lwevent_dtor* old_dtor)
|
void lwevent_set_dtor(struct lwevent* ev, lwevent_dtor dtor)
|
||||||
{
|
{
|
||||||
if(old_dtor) *old_dtor = ev->dtor;
|
|
||||||
ev->dtor = dtor;
|
ev->dtor = dtor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lwevent_set_autodestroy(struct lwevent* ev, int autodestroy, int* old_autodestroy)
|
void lwevent_set_autodestroy(struct lwevent* ev, int autodestroy)
|
||||||
{
|
{
|
||||||
if(old_autodestroy) *old_autodestroy = ev->autodestroy;
|
|
||||||
ev->autodestroy = autodestroy;
|
ev->autodestroy = autodestroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,15 +54,11 @@ int lwevent_get_autodestroy(const struct lwevent* ev) __attribute__((nonnull, wa
|
||||||
|
|
||||||
\param ev Event object.
|
\param ev Event object.
|
||||||
\param events New bitmask of events to monitor (see \c epoll_ctl(2)).
|
\param events New bitmask of events to monitor (see \c epoll_ctl(2)).
|
||||||
\param[out] old_events Previous bitmask stored here. May be 0.
|
|
||||||
\retval 0 on success.
|
\retval 0 on success.
|
||||||
\retval -1 on error (and see \a errno).
|
\retval -1 on error (and see \a errno).
|
||||||
|
|
||||||
Changes the events being monitored for the file descriptor associated with \a ev. This calls
|
Changes the events being monitored for the file descriptor associated with \a ev. This calls
|
||||||
\c epoll_ctl(2) so may fail; a return value of 0 indicates success. If the application wishes to
|
\c epoll_ctl(2), which may fail; a return value of 0 indicates success.
|
||||||
retrieve the bitmask in force before the change, it may pass a pointer to an integer in
|
|
||||||
\a old_events; the previous value will be stored there. The pointer may be 0 if the previous value
|
|
||||||
is not required.
|
|
||||||
|
|
||||||
Only some values are valid for the \a events bitmask (non-authoritative list: \c EPOLLIN,
|
Only some values are valid for the \a events bitmask (non-authoritative list: \c EPOLLIN,
|
||||||
\c EPOLLOUT, \c EPOLLRDHUP, \c EPOLLPRI, \c EPOLLET, \c EPOLLONESHOT). Returned events may have
|
\c EPOLLOUT, \c EPOLLRDHUP, \c EPOLLPRI, \c EPOLLET, \c EPOLLONESHOT). Returned events may have
|
||||||
|
@ -74,8 +70,8 @@ details.
|
||||||
lwevent_reactivate() function.
|
lwevent_reactivate() function.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
int lwevent_set_events(struct lwevent* ev, int events, int* old_events)
|
int lwevent_set_events(struct lwevent* ev, int events)
|
||||||
__attribute__((warn_unused_result, nonnull(1)));
|
__attribute__((warn_unused_result, nonnull));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,15 +79,12 @@ int lwevent_set_events(struct lwevent* ev, int events, int* old_events)
|
||||||
|
|
||||||
\param ev Event object.
|
\param ev Event object.
|
||||||
\param callback Pointer to new callback function.
|
\param callback Pointer to new callback function.
|
||||||
\param[out] old_callback Previous callback function pointer stored here. May be 0.
|
|
||||||
|
|
||||||
Changes the callback function associated with \a ev. If the program wishes to retrieve the previous
|
Changes the callback function associated with \a ev.
|
||||||
callback function pointer, it may pass a pointer-to-function-pointer in \a old_callback. This may be
|
|
||||||
left null if not required.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void lwevent_set_callback(struct lwevent* ev, lwevent_callback callback,
|
void lwevent_set_callback(struct lwevent* ev, lwevent_callback callback)
|
||||||
lwevent_callback* old_callback) __attribute__((nonnull(1, 2)));
|
__attribute__((nonnull));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,14 +92,11 @@ void lwevent_set_callback(struct lwevent* ev, lwevent_callback callback,
|
||||||
|
|
||||||
\param ev Event object.
|
\param ev Event object.
|
||||||
\param user Pointer to new user object. May be 0 to clear.
|
\param user Pointer to new user object. May be 0 to clear.
|
||||||
\param[out] old_user Previous user object pointer stored here. May be 0.
|
|
||||||
|
|
||||||
Changes the user pointer associated with \a ev. If the program wishes to retrieve the previous user
|
Changes the user pointer associated with \a ev.
|
||||||
pointer, it may pass a pointer-to-pointer in \a old_user. This may be left null if not required.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void lwevent_set_user(struct lwevent* ev, void* user, void** old_user)
|
void lwevent_set_user(struct lwevent* ev, void* user) __attribute__((nonnull));
|
||||||
__attribute__((nonnull(1)));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,18 +104,13 @@ void lwevent_set_user(struct lwevent* ev, void* user, void** old_user)
|
||||||
|
|
||||||
\param ev Event object.
|
\param ev Event object.
|
||||||
\param dtor Pointer to destructor object to call when \a ev is freed. May be 0 to clear.
|
\param dtor Pointer to destructor object to call when \a ev is freed. May be 0 to clear.
|
||||||
\param[out] old_dtor Previous destructor function pointer stored here. May be 0.
|
|
||||||
|
|
||||||
Changes the destructor function associated with \a ev. The destructor function (if one has been
|
Changes the destructor function associated with \a ev. The destructor function (if one has been
|
||||||
registered) is called from within lwevent_free(). There is no default destructor. It can be cleared
|
registered) is called from within lwevent_free(). There is no default destructor. It can be cleared
|
||||||
by passing \a dtor as 0.
|
by passing \a dtor as 0.
|
||||||
|
|
||||||
If the program wishes to retrieve the previous destructor function pointer, it may pass a
|
|
||||||
pointer-to-function-pointer in \a old_dtor. This may be left null if not required.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void lwevent_set_dtor(struct lwevent* ev, lwevent_dtor dtor, lwevent_dtor* old_dtor)
|
void lwevent_set_dtor(struct lwevent* ev, lwevent_dtor dtor) __attribute__((nonnull));
|
||||||
__attribute__((nonnull(1)));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,7 +118,6 @@ void lwevent_set_dtor(struct lwevent* ev, lwevent_dtor dtor, lwevent_dtor* old_d
|
||||||
|
|
||||||
\param ev Event object.
|
\param ev Event object.
|
||||||
\param autodestroy Bitmask of events which destroy object if received.
|
\param autodestroy Bitmask of events which destroy object if received.
|
||||||
\param[out] old_autodestroy Previous bitmask stored here. May be 0.
|
|
||||||
|
|
||||||
The autodestroy functionality causes the event object \a ev to be automatically passed to
|
The autodestroy functionality causes the event object \a ev to be automatically passed to
|
||||||
lwevent_free() if any specified event occurs. You may pass ~0 to autodestroy on any event. See
|
lwevent_free() if any specified event occurs. You may pass ~0 to autodestroy on any event. See
|
||||||
|
@ -141,8 +125,8 @@ lwevent_free() if any specified event occurs. You may pass ~0 to autodestroy on
|
||||||
\c EPOLLRDHUP, \c EPOLLPRI, \c EPOLLERR, \c EPOLLHUP).
|
\c EPOLLRDHUP, \c EPOLLPRI, \c EPOLLERR, \c EPOLLHUP).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void lwevent_set_autodestroy(struct lwevent* ev, int autodestroy, int* old_autodestroy)
|
void lwevent_set_autodestroy(struct lwevent* ev, int autodestroy)
|
||||||
__attribute__((nonnull(1)));
|
__attribute__((nonnull));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ struct lwevent_signal* lwevent_signalfd(const sigset_t* mask, lwevent_signalcb c
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lwevent_set_user(si->ev, si, 0);
|
lwevent_set_user(si->ev, si);
|
||||||
return si;
|
return si;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue