Compare commits

..

No commits in common. "master" and "1.0.0" have entirely different histories.

4 changed files with 6 additions and 14 deletions

View File

@ -90,7 +90,7 @@ void lwevent_exit(void)
int lwevent_loop(void) int lwevent_loop(void)
{ {
while(!lwevent_loop_exit) { while(!lwevent_loop_exit) {
if(lwevent_wait(-1, 0) == -1) { if(lwevent_wait(-1) == -1) {
if(errno == EINTR) continue; if(errno == EINTR) continue;
return -1; return -1;
} }
@ -125,7 +125,7 @@ static void _lwevent_invalid(struct lwevent* ev)
* Wrapper around epoll_wait(2). For every returned event, we assume the object has an associated * Wrapper around epoll_wait(2). For every returned event, we assume the object has an associated
* struct lwevent in the struct epoll_event. * struct lwevent in the struct epoll_event.
*/ */
int lwevent_wait(int timeout_ms, void (*before_loop)(void)) int lwevent_wait(int timeout_ms)
{ {
int ret, i, revents; int ret, i, revents;
struct lwevent* ev; struct lwevent* ev;
@ -137,8 +137,6 @@ int lwevent_wait(int timeout_ms, void (*before_loop)(void))
ret = epoll_wait(lwevent_epoll_fd, _lw_revents, _lw_revents_size, timeout_ms); ret = epoll_wait(lwevent_epoll_fd, _lw_revents, _lw_revents_size, timeout_ms);
if(ret == -1) return -1; if(ret == -1) return -1;
if(before_loop) before_loop();
/* process returned events */ /* process returned events */
for(i = 0; i < ret; ++i) { for(i = 0; i < ret; ++i) {
ev = (struct lwevent*)(_lw_revents[i].data.ptr); ev = (struct lwevent*)(_lw_revents[i].data.ptr);

View File

@ -61,7 +61,7 @@ extern volatile int lwevent_loop_exit;
\retval -1 on error (system call failed; see \a errno). \retval -1 on error (system call failed; see \a errno).
This function will call lwevent_wait() in a loop forever. The loop can be aborted by setting the This function will call lwevent_wait() in a loop forever. The loop can be aborted by setting the
flag \ref lwevent_loop_exit to non-zero. The loop will also be aborted if lwevent_wait() returns an flag lwevent_loop_exit to non-zero. The loop will also be aborted if lwevent_wait() returns an
error (in which case \a errno can be used to determine the error). error (in which case \a errno can be used to determine the error).
*/ */
@ -73,8 +73,6 @@ int lwevent_loop(void);
\param timeout_ms A timeout, in milliseconds. This function will return as soon as any events occur, \param timeout_ms A timeout, in milliseconds. This function will return as soon as any events occur,
but will return after \a timeout_ms milliseconds have elapsed. but will return after \a timeout_ms milliseconds have elapsed.
\param before_loop If specified, a function which is called after \c epoll_wait(2) but before
processing events. May be 0.
\returns Number of events processed. \returns Number of events processed.
\retval 0 on timeout. \retval 0 on timeout.
\retval -1 on error (system call failed; see \a errno). \retval -1 on error (system call failed; see \a errno).
@ -87,16 +85,12 @@ objects that are closed during the callbacks.
\a timeout_ms may be specified as a negative number to disable timeouts and wait forever, or as 0 to \a timeout_ms may be specified as a negative number to disable timeouts and wait forever, or as 0 to
return immediately even if no events are available. A positive number is a duration in milliseconds. return immediately even if no events are available. A positive number is a duration in milliseconds.
\a before_loop may be used to run a function before looping over any returned events. Some programs
may wish to record the time at the top of the event loop, for example, to avoid polling for it
multiple times while processing events.
\note If a signal is received while in \c epoll_wait(2), this function will return -1 and \a errno \note If a signal is received while in \c epoll_wait(2), this function will return -1 and \a errno
will be set to \c EINTR. This is not a permanent error condition. lwevent_loop() will catch this will be set to \c EINTR. This is not a permanent error condition. lwevent_loop() will catch this
condition and continue to loop. condition and continue to loop.
*/ */
int lwevent_wait(int timeout_ms, void (*before_loop)(void)); int lwevent_wait(int timeout_ms);

View File

@ -9,7 +9,7 @@
# SOMAJOR is included in the library's soname, and needs to be bumped # SOMAJOR is included in the library's soname, and needs to be bumped
# after a binary-incompatible release. It is a single integer. # after a binary-incompatible release. It is a single integer.
SOMAJOR=1 SOMAJOR=0
# SOMICRO is bumped every time there is a binary-compatible release. # SOMICRO is bumped every time there is a binary-compatible release.
SOMICRO=0 SOMICRO=0

View File

@ -11,7 +11,7 @@
# expected to be in 'major.minor.micro' format. # expected to be in 'major.minor.micro' format.
VERMAJOR=1 VERMAJOR=1
VERMINOR=0 VERMINOR=0
VERMICRO=1 VERMICRO=0
# kate: replace-trailing-space-save true; space-indent true; tab-width 4; # kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4:syntax=sh # vim: expandtab:ts=4:sw=4:syntax=sh