couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [10/35] git commit: New couch_event:listen/4 API
Date Fri, 01 Aug 2014 09:10:06 GMT
New couch_event:listen/4 API

This function doesn't return but allows a process to become an event
listener. Useful in RPC situations to avoid spawning an extra process
and doubling the message passing.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/commit/b00c879d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/tree/b00c879d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/diff/b00c879d

Branch: refs/heads/windsor-merge
Commit: b00c879dabef34edb30c1ce6606e2b7e700532c8
Parents: bf25e9f
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Wed Apr 24 11:33:21 2013 -0500
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Jul 30 17:36:52 2014 +0100

----------------------------------------------------------------------
 src/couch_event.erl              |  4 ++++
 src/couch_event_listener_mfa.erl | 12 +++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/blob/b00c879d/src/couch_event.erl
----------------------------------------------------------------------
diff --git a/src/couch_event.erl b/src/couch_event.erl
index fd04824..7e77bff 100644
--- a/src/couch_event.erl
+++ b/src/couch_event.erl
@@ -38,6 +38,10 @@ notify(DbName, Event) ->
     gen_server:cast(?DIST, {DbName, Event}).
 
 
+listen(Module, Function, State, Options) ->
+    couch_event_listener_mfa:enter_loop(Module, Function, State, Options).
+
+
 link_listener(Module, Function, State, Options) ->
     couch_event_listener_mfa:start_link(Module, Function, State, Options).
 

http://git-wip-us.apache.org/repos/asf/couchdb-couch-event/blob/b00c879d/src/couch_event_listener_mfa.erl
----------------------------------------------------------------------
diff --git a/src/couch_event_listener_mfa.erl b/src/couch_event_listener_mfa.erl
index 2231448..81adb8f 100644
--- a/src/couch_event_listener_mfa.erl
+++ b/src/couch_event_listener_mfa.erl
@@ -16,7 +16,8 @@
 
 -export([
     start_link/4,
-    stop/1
+    enter_loop/4,
+    stop/1,
 ]).
 
 -export([
@@ -41,6 +42,15 @@ start_link(Mod, Func, State, Options) ->
     couch_event_listener:start_link(?MODULE, Arg, Options).
 
 
+enter_loop(Mod, Func, State, Options) ->
+    St = #st{
+        mod = Mod,
+        func = Func,
+        state = State
+    },
+    couch_event_listener:enter_loop(?MODULE, St, Options).
+
+
 stop(Pid) ->
     couch_event_listener:stop(Pid).
 


Mime
View raw message