- Rename all _create() functions --> _init()
- Rename all _delete() functions --> _stop()
- Watchers are automatically started, except
- Timer watchers are automatically started by uev_run()
- Allow I/O watchers to watch either EV_READ/EV_WRITE or both events
- Extend callbacks with a received events field
- Remove calloc()/free(), let user handle this
- Make event has-a context when initializing it => simplifies API
- Internal uev_watcher_*() API mostly handles epoll stop/start
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Split libuev.c into one file per watcher type, mostly to give a better
overview and ease of maintenance, but also to help the linker.
Unfortunately this steals a few bytes when linking a full blown app, but
for apps that, e.g., only need I/O watchers and no timers the resulting
binary will be smaller. This applies to static binaries that are more
common in embedded systems.
$ size libuev.a libuev.so.1
text data bss dec hex filename
999 0 0 999 3e7 main.o (ex libuev.a)
90 0 0 90 5a io.o (ex libuev.a)
490 0 0 490 1ea timer.o (ex libuev.a)
4380 696 8 5084 13dc libuev.so.1
Also, move uev.h back to top from include/libuev/uev.h since a separate
namespace is not needed after the removal of the OpenBSD queue.h copy.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- Cleanup code
- Further polish on total size using black magic
- Remove OpenBSD queue.h, code simplied so much now it's not needed anymore.
Instead we can rely on the standard GNU/Linux sys/queue.h (old BSD copy)
$ size libuev.a libuev.so.1
text data bss dec hex filename
1520 0 0 1520 5f0 libuev.o (ex libuev.a)
4194 680 8 4882 1312 libuev.so.1
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- Remove double book keeping, the kernel does all the heavy lifting now
- Trim the amount of #includes
- Use LIST_ instead of TAILQ_ now that we no longer handle timers ourselves
Original LibUEvent
$ size libuevent.a libuevent.so.1
text data bss dec hex filename
2610 0 8 2618 a3a libuevent.o (ex libuevent.a)
5266 648 16 5930 172a libuevent.so.1
Refactored libuev:
$ size libuev.a libuev.so.1
text data bss dec hex filename
1557 0 0 1557 615 libuev.o (ex libuev.a)
4186 672 8 4866 1302 libuev.so.1
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This is a major refactor of the original design by Flemming Madsen. It
converts the library timers from poll() to timerfd, which at the same
time also unifies the file and timer watchers into one design. The idea
is to also add signalfd to the mix later on.
Also a couple of hundred kilobytes smaller, although size a secondary
goal. The primary goal is to further simplify the internal design and
to continuously strive to employ modern APIs.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Refactor uev_timer_create() to support a periodic (msec) argument. For
such timers libuev automaticlly respawns them. Effectively resetting
the timeout using the period value.
Also, refactor argument order to uev_timer_create() and uev_io_create().
Rename UEV_FHIN, UEV_FHOUT to UEV_DIR_INBOUND and UEV_DIR_OUTBOUND.
Remove unnecessary return value for watcher callbacks. What would those
have been usefu for, ever? Not even the original code checked the return
value after calling a handler.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Simplifed uev_io_t by removing uev_io_rem_t completely. A refactor that
would not have been possible without the BSD queue.h API. This makes
the code readable and thus maintainable and less error prone.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This fork is called libuev and will focus solely on embedded Linux
systems using C. Patches for other UNIX-like operating systems are
welcome.
- Remove Lua support, will not be used.
- Rename from LibUEvent to libuev where applicable
- Add project's MIT license to top of all files, as is customary
- Add a LICENSE file, as is customary
This MIT licensed code was cloned from the Mercurial repository at
Google http://code.google.com/p/libuevent/ which had mislabled the
license as "New BSD License", which is wrong. The actual license
of the project is https://en.wikipedia.org/wiki/MIT_License
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>