Permalink
Browse files

Async socket notifications using libev

Import of libev socket notifications for Erlang by Gregory Haskins.
  • Loading branch information...
0 parents commit 122b30e76bc3dcde585ffdfe6213656cdd74865b @msantos committed Dec 7, 2011
Showing with 7,124 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +21 −0 Makefile
  3. +72 −0 README.md
  4. +351 −0 c_src/everl.c
  5. +56 −0 c_src/everl.h
  6. +34 −0 c_src/everl_ev.c
  7. +36 −0 c_src/everl_ev.h
  8. +3,913 −0 c_src/libev/ev.c
  9. +829 −0 c_src/libev/ev.h
  10. +266 −0 c_src/libev/ev_epoll.c
  11. +198 −0 c_src/libev/ev_kqueue.c
  12. +148 −0 c_src/libev/ev_poll.c
  13. +179 −0 c_src/libev/ev_port.c
  14. +310 −0 c_src/libev/ev_select.c
  15. +203 −0 c_src/libev/ev_vars.h
  16. +196 −0 c_src/libev/ev_wrap.h
  17. +32 −0 include/everl.hrl
  18. +11 −0 rebar.config
  19. +3 −0 src/everl.app.src
  20. +88 −0 src/everl.erl
  21. +176 −0 test/everl_tests.erl
@@ -0,0 +1,2 @@
+*.[oa]
+*.beam
@@ -0,0 +1,21 @@
+REBAR=$(shell which rebar || echo ./rebar)
+
+all: dirs compile
+
+./rebar:
+ erl -noshell -s inets start -s ssl start \
+ -eval 'httpc:request(get, {"https://github.com/downloads/basho/rebar/rebar", []}, [], [{stream, "./rebar"}])' \
+ -s inets stop -s init stop
+ chmod +x ./rebar
+
+dirs:
+ -@mkdir -p priv
+
+compile: $(REBAR)
+ @$(REBAR) compile
+
+clean: $(REBAR)
+ @$(REBAR) clean
+
+deps: $(REBAR)
+ @$(REBAR) get-deps
@@ -0,0 +1,72 @@
+everl is an Erlang library for asynchronously generating socket
+notifications using libev. everl lets you watch file descriptors for
+events and sends your process a message whenever the socket state changes.
+
+
+## ABOUT
+
+everl started out as a contribution to procket by Gregory Haskins
+(https://github.com/ghaskins) but it was so awesome I decided to move
+it into its own repository. The original patch is here:
+
+ https://github.com/msantos/procket/commit/1345e3b4a00ea10af24bd1cd9d52fa1b28de1b2a
+ https://github.com/msantos/procket/pull/2
+
+libev was written by Marc Alexander Lehmann and is available from:
+
+ http://software.schmorp.de/pkg/libev.html
+
+
+## FEATURES
+
+
+## EXPORTS
+
+ create(FD, Flags) -> {ok, Handle} | {error, posix()}
+
+ Types FD = int()
+ Flags = [Flag]
+ Flag = read | write
+ Handle = resource()
+
+ Returns a handle for watching events on the file descriptor.
+
+ arm(Handle) -> ok
+
+ Types Handle = resource()
+
+ Initiates notifications on the file descriptor. The watch handle
+ must be re-armed after each notification is received.
+
+ The process creating the handle will receive:
+
+ {everl_watcher, FD, Event}
+
+ Where
+
+ FD is the file descriptor associated with the watch handle.
+
+ Event is an integer:
+
+ 1 (READ): file descriptor is ready for reading
+ 2 (WRITE): file descriptor is ready for writing
+ 3 (RDWR): file descriptor is ready for reading and writing
+
+ disarm(Handle) -> ok
+
+ Types Handle = resource()
+
+ Disable notifications for the file descriptor and close the
+ watch handle.
+
+
+## USING IT
+
+
+## TODO
+
+* Documentation and examples
+
+* Support all of libev
+
+* API changes
Oops, something went wrong.

0 comments on commit 122b30e

Please sign in to comment.