mirror of
https://github.com/troglobit/libuev.git
synced 2026-11-02 12:30:29 +00:00
Fix TODO: Add uev_*_start() functions.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
bfcea55b1e
commit
2f8c45f438
6 files changed
+73
-8
No files matched your search
@@ -23,6 +23,8 @@
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "uev.h"
|
||||
|
||||
|
||||
@@ -39,12 +41,14 @@
|
||||
*/
|
||||
int uev_io_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int fd, int events)
|
||||
{
|
||||
if (fd < 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (uev_watcher_init(ctx, w, UEV_IO_TYPE, cb, arg, fd, events))
|
||||
return -1;
|
||||
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
|
||||
return uev_watcher_start(w);
|
||||
}
|
||||
|
||||
@@ -67,15 +71,28 @@ int uev_io_set(uev_t *w, int fd, int events)
|
||||
return uev_io_init(w->ctx, w, (uev_cb_t *)w->cb, w->arg, fd, events);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start an I/O watcher
|
||||
* @param w Watcher to start (again)
|
||||
*
|
||||
* @return POSIX OK(0) or non-zero with @param errno set on error.
|
||||
*/
|
||||
int uev_io_start(uev_t *w)
|
||||
{
|
||||
return uev_io_set(w, w->fd, w->events);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop an I/O watcher
|
||||
* @param w Pointer to an uev_t watcher
|
||||
* @param w Watcher to stop
|
||||
*
|
||||
* @return POSIX OK(0) or non-zero with @param errno set on error.
|
||||
*/
|
||||
int uev_io_stop(uev_t *w)
|
||||
{
|
||||
return uev_watcher_stop(w);
|
||||
int status = uev_watcher_stop(w);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user