mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-23 11:24:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4255ebb9c6 | ||
|
|
930cce21fa | ||
|
|
addd60db22 | ||
|
|
e3d40ef010 | ||
|
|
618b50ee88 | ||
|
|
f64301194a | ||
|
|
bdbfe809ab | ||
|
|
2742adfe98 |
No files matched your search
+11
-1
@@ -4,6 +4,14 @@ Change Log
|
|||||||
All notable changes to the project are documented in this file.
|
All notable changes to the project are documented in this file.
|
||||||
|
|
||||||
|
|
||||||
|
[v1.4.2][] - 2016-06-25
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- Add range checks for `period` and `timeout` to `uev_timer_init()` and
|
||||||
|
`uev_timer_set()`. If either on is `< 0` libuEv now return `ERANGE`.
|
||||||
|
|
||||||
|
|
||||||
[v1.4.1][] - 2016-04-22
|
[v1.4.1][] - 2016-04-22
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
@@ -233,7 +241,9 @@ v0.0.1 - 2012-03-17
|
|||||||
Lua users mailing list.
|
Lua users mailing list.
|
||||||
|
|
||||||
|
|
||||||
[UNRELEASED]: https://github.com/troglobit/libuev/compare/v1.4.0...HEAD
|
[UNRELEASED]: https://github.com/troglobit/libuev/compare/v1.4.2...HEAD
|
||||||
|
[v1.4.2]: https://github.com/troglobit/libuev/compare/v1.4.1...v1.4.2
|
||||||
|
[v1.4.1]: https://github.com/troglobit/libuev/compare/v1.4.0...v1.4.1
|
||||||
[v1.4.0]: https://github.com/troglobit/libuev/compare/v1.3.1...v1.4.0
|
[v1.4.0]: https://github.com/troglobit/libuev/compare/v1.3.1...v1.4.0
|
||||||
[v1.3.1]: https://github.com/troglobit/libuev/compare/v1.3.0...v1.3.1
|
[v1.3.1]: https://github.com/troglobit/libuev/compare/v1.3.0...v1.3.1
|
||||||
[v1.3.0]: https://github.com/troglobit/libuev/compare/v1.2.3...v1.3.0
|
[v1.3.0]: https://github.com/troglobit/libuev/compare/v1.2.3...v1.3.0
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ libuEv | Simple event loop for Linux
|
|||||||
[![Travis Status][]][Travis] [![Coverity Status][]][Coverity Scan]
|
[![Travis Status][]][Travis] [![Coverity Status][]][Coverity Scan]
|
||||||
|
|
||||||
|
|
||||||
Table of Contents
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
* [Introduction](#introduction)
|
* [Introduction](#introduction)
|
||||||
* [API](#api)
|
* [API](#api)
|
||||||
* [Create an Event Context](#create-an-event-context)
|
* [Create an Event Context](#create-an-event-context)
|
||||||
@@ -15,50 +12,22 @@ Table of Contents
|
|||||||
* [Using -luev](#using--luev)
|
* [Using -luev](#using--luev)
|
||||||
* [Joystick Example](#joystick-example)
|
* [Joystick Example](#joystick-example)
|
||||||
* [Build & Install](#build--install)
|
* [Build & Install](#build--install)
|
||||||
|
* [Background](#background)
|
||||||
* [Origin & References](#origin--references)
|
* [Origin & References](#origin--references)
|
||||||
|
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
------------
|
------------
|
||||||
|
|
||||||
> “Why an event loop, why not use threads?”
|
|
||||||
|
|
||||||
With the advent of light-weight processes (threads) programmers these
|
|
||||||
days have a [golden hammer](http://c2.com/cgi/wiki?GoldenHammer) they
|
|
||||||
often swing without consideration. Event loops and non-blocking I/O is
|
|
||||||
often a far easier approach, as well as less error prone.
|
|
||||||
|
|
||||||
The purpose of many applications is, with a little logic sprinkled on
|
|
||||||
top, to act on network packets entering an interface, timeouts expiring,
|
|
||||||
mouse clicks, or other types of events. Such applications are often
|
|
||||||
very well suited to use an event loop.
|
|
||||||
|
|
||||||
Applications that need to churn massively parallel algorithms are more
|
|
||||||
suitable for running multiple (independent) threads on several CPU
|
|
||||||
cores. However, threaded applications must deal with the side effects
|
|
||||||
of concurrency, like race conditions, deadlocks, live locks, etc.
|
|
||||||
Writing error free threaded applications is hard, debugging them can be
|
|
||||||
even harder.
|
|
||||||
|
|
||||||
Sometimes the combination of multiple threads *and* an event loop per
|
|
||||||
thread can be the best approach, but each application of course needs to
|
|
||||||
be broken down individually to find the most optimal approach. Do keep
|
|
||||||
in mind, however, that not all systems your application will run on have
|
|
||||||
multiple CPU cores -- some small embedded systems still use a single CPU
|
|
||||||
core, even though they run Linux, with multiple threads a program may
|
|
||||||
actually run slower! Always profile your program, and if possible, test
|
|
||||||
it on different architectures.
|
|
||||||
|
|
||||||
[libuEv][] is a simple event loop in the style of the more established
|
[libuEv][] is a simple event loop in the style of the more established
|
||||||
[libevent][1], [libev][2] and the venerable [Xt(3)][3] event loop. The
|
[libevent][1], [libev][2] and the venerable [Xt(3)][3] event loop. The
|
||||||
*u* (micro) in the name refers to both the small feature set and the
|
*u* (micro) in the name refers to both the small feature set and the
|
||||||
small size overhead impact of the library. The primary target of
|
small size overhead impact of the library.
|
||||||
[libuEv][] is a modern Linux system.
|
|
||||||
|
|
||||||
Experienced developers may appreciate that [libuEv][] is built on top of
|
Experienced developers may appreciate that [libuEv][] is built on top of
|
||||||
modern Linux APIs: epoll, timerfd and signalfd. Note, a certain amount
|
modern Linux APIs: epoll, timerfd and signalfd. Note however, a certain
|
||||||
of care is needed when dealing with APIs that employ signalfd. For
|
amount of care is needed when dealing with APIs that employ signalfd.
|
||||||
details, see [this article][4] at [lwn.net](http://lwn.net).
|
For details, see [this article][4] at [lwn.net](http://lwn.net).
|
||||||
|
|
||||||
> “Event driven software improves concurrency” -- [Dave Zarzycki, Apple][]
|
> “Event driven software improves concurrency” -- [Dave Zarzycki, Apple][]
|
||||||
|
|
||||||
@@ -306,7 +275,7 @@ Build & Install
|
|||||||
---------------
|
---------------
|
||||||
|
|
||||||
The library is built for and developed on GNU/Linux systems, patches to
|
The library is built for and developed on GNU/Linux systems, patches to
|
||||||
support *BSD and its kqueue interface are most welcome.
|
support *BSD and its [kqueue][] interface are most welcome.
|
||||||
|
|
||||||
libuEv use the GNU configure and build system. To try out the bundled
|
libuEv use the GNU configure and build system. To try out the bundled
|
||||||
examples, use the `--enable-examples` switch to the `configure` script.
|
examples, use the `--enable-examples` switch to the `configure` script.
|
||||||
@@ -319,6 +288,38 @@ examples, use the `--enable-examples` switch to the `configure` script.
|
|||||||
The resulting .so file is ~14 kiB (<kbd>make install-strip</kbd>).
|
The resulting .so file is ~14 kiB (<kbd>make install-strip</kbd>).
|
||||||
|
|
||||||
|
|
||||||
|
Background
|
||||||
|
----------
|
||||||
|
|
||||||
|
> “Why an event loop, why not use threads?”
|
||||||
|
|
||||||
|
With the advent of light-weight processes (threads) programmers these
|
||||||
|
days have a [golden hammer](http://c2.com/cgi/wiki?GoldenHammer) they
|
||||||
|
often swing without consideration. Event loops and non-blocking I/O is
|
||||||
|
often a far easier approach, as well as less error prone.
|
||||||
|
|
||||||
|
The purpose of many applications is, with a little logic sprinkled on
|
||||||
|
top, to act on network packets entering an interface, timeouts expiring,
|
||||||
|
mouse clicks, or other types of events. Such applications are often
|
||||||
|
very well suited to use an event loop.
|
||||||
|
|
||||||
|
Applications that need to churn massively parallel algorithms are more
|
||||||
|
suitable for running multiple (independent) threads on several CPU
|
||||||
|
cores. However, threaded applications must deal with the side effects
|
||||||
|
of concurrency, like race conditions, deadlocks, live locks, etc.
|
||||||
|
Writing error free threaded applications is hard, debugging them can be
|
||||||
|
even harder.
|
||||||
|
|
||||||
|
Sometimes the combination of multiple threads *and* an event loop per
|
||||||
|
thread can be the best approach, but each application of course needs to
|
||||||
|
be broken down individually to find the most optimal approach. Do keep
|
||||||
|
in mind, however, that not all systems your application will run on have
|
||||||
|
multiple CPU cores -- some small embedded systems still use a single CPU
|
||||||
|
core, even though they run Linux, with multiple threads a program may
|
||||||
|
actually run slower! Always profile your program, and if possible, test
|
||||||
|
it on different architectures.
|
||||||
|
|
||||||
|
|
||||||
Origin & References
|
Origin & References
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
@@ -344,6 +345,7 @@ event library used for inspiration is the very small [Picoev][9] by
|
|||||||
[Coverity Scan]: https://scan.coverity.com/projects/3846
|
[Coverity Scan]: https://scan.coverity.com/projects/3846
|
||||||
[Coverity Status]: https://scan.coverity.com/projects/3846/badge.svg
|
[Coverity Status]: https://scan.coverity.com/projects/3846/badge.svg
|
||||||
[LibuEv]: https://github.com/troglobit/libuev
|
[LibuEv]: https://github.com/troglobit/libuev
|
||||||
|
[kqueue]: https://github.com/mheily/libkqueue
|
||||||
[Oku Kazuho]: https://github.com/kazuho
|
[Oku Kazuho]: https://github.com/kazuho
|
||||||
[Mark Lehmann]: http://software.schmorp.de
|
[Mark Lehmann]: http://software.schmorp.de
|
||||||
[Joachim Nilsson]: http://troglobit.com
|
[Joachim Nilsson]: http://troglobit.com
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
LibuEv TODO
|
LibuEv TODO
|
||||||
===========
|
===========
|
||||||
|
|
||||||
* Make port to *BSD kqueue API, http://en.wikipedia.org/wiki/Kqueue
|
* Port to *BSD kqueue API, http://en.wikipedia.org/wiki/Kqueue
|
||||||
|
Also in UNIX Network Progamming, by W. Richard Stevens 3rd ed.
|
||||||
|
* Restore Lua bindings now that libuEv itself has stabilized
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
AC_INIT(libuev, 1.4.1, https://github.com/troglobit/libuev/issues)
|
AC_INIT(libuev, 1.4.2, https://github.com/troglobit/libuev/issues)
|
||||||
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
|
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,11 @@ int uev_timer_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int timeou
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
if (timeout < 0 || period < 0) {
|
||||||
|
errno = ERANGE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -100,6 +105,11 @@ int uev_timer_set(uev_t *w, int timeout, int period)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (timeout < 0 || period < 0) {
|
||||||
|
errno = ERANGE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle stopped timers */
|
/* Handle stopped timers */
|
||||||
if (w->fd < 0) {
|
if (w->fd < 0) {
|
||||||
/* Timer already stopped */
|
/* Timer already stopped */
|
||||||
|
|||||||
Reference in new issue
Block a user