Permalink
Browse files

custom data owner interface is replaced with gen_server/gen_fsm call/…

…cast notations
  • Loading branch information...
1 parent f86ea02 commit 89b8052841fa3d7e9377636b2a5f7e8d8aab9262 @fogfish committed Apr 25, 2012
View
@@ -16,12 +16,12 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA or retrieve online http://www.opensource.org/licenses/lgpl-3.0.html
#
-SUBDIRS = test examples
+SUBDIRS = test priv
+ERL_FLAGS = +P 90000000
pts_SRC = \
src/pts.erl \
src/pns.erl \
- src/pts_prot.erl \
src/pts_sup.erl \
src/pts_app.erl
@@ -32,8 +32,5 @@ nobase_pkgliberl_SCRIPTS = \
CLEANFILES = $(nobase_pkgliberl_SCRIPTS)
EXTRA_DIST = $(pts_SRC)
-run-example:
- $(ERL) -pa ./ebin -pa ./examples/ebin +P 90000000
-
@MAKE_GNUWEB@
View
@@ -159,6 +159,7 @@ ERLANG_APPS = @ERLANG_APPS@
ERLANG_LIBS = @ERLANG_LIBS@
ERLC = @ERLC@
ERLCFLAGS = @ERLCFLAGS@
+ESCRIPT = @ESCRIPT@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -219,6 +220,7 @@ mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgliberldir = @pkgliberldir@
+pkglibprivdir = @pkglibprivdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
@@ -249,11 +251,11 @@ top_srcdir = @top_srcdir@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA or retrieve online http://www.opensource.org/licenses/lgpl-3.0.html
#
-SUBDIRS = test examples
+SUBDIRS = test priv
+ERL_FLAGS = +P 90000000
pts_SRC = \
src/pts.erl \
src/pns.erl \
- src/pts_prot.erl \
src/pts_sup.erl \
src/pts_app.erl
@@ -810,9 +812,6 @@ uninstall-am: uninstall-nobase_pkgliberlSCRIPTS
uninstall-nobase_pkgliberlSCRIPTS
-run-example:
- $(ERL) -pa ./ebin -pa ./examples/ebin +P 90000000
-
@MAKE_GNUWEB@
# Tell versions [3.59,3.63) of GNU make to not export all variables.
View
35 README
@@ -44,7 +44,7 @@ Use-cases
The library assumes existence of two type of processes `actors':
- * data owner is an Erlang/OTP process that holds/ chunk of data and operates
+ * data owner is an Erlang/OTP process that holds chunk of data and operates
its life-cycle.
* data consumer is process that leases data for transient operation
@@ -65,7 +65,7 @@ src/pts.erl file for detailed interface specification and/or example cache
application.
%% create a new table and define a factory function
- ok = pts:new(mytable, [{factory, fun my_entry_sup:create/2}]),
+ ok = pts:new(mytable, [{factory, fun my_entry_sup:create/1}]),
%% put a value into process bound to mykey, if such process do not exists
%% the factory function is called to spawn a new process
@@ -84,17 +84,21 @@ Protocol
Each `data owner' process has to be complient with asynchronous protocol:
- 1. Store data:
- ----{pts_req_put, Pid, Key, Val}--->
- <---{pts_rsp_put, Status}-----------
+ 1. Create
+ ----init([pts, Own, Key])--->
+ <---{ok, Pid}----------------
+
+ 2. Store data:
+ ----{put, Val}-------------->
+ <---ok-----------------------
2. Read data
- ----{pts_req_get, Pid, Key}-------->
- <---{pts_rsp_get, {ok, Val}}--------
+ ----{get, Key}-------------->
+ <---{ok, Val}}---------------
3. Remove data
- ----{pts_req_remove, Pid, Key}----->
- <---{pts_rsp_remove, Status}--------
+ ----{remove, Key}----------->
+ <---ok-----------------------
see the examples/cache_entry.erl for example.
@@ -107,7 +111,7 @@ Performance
pts is compared to ets for single `data consumer' over example cache
application. The 1KB data block(s) are used.
- version 0.3.x
+ version 0.4.x
Write 10 100 1000 10000
--------------------------------------------------
@@ -119,17 +123,6 @@ application. The 1KB data block(s) are used.
pts 0.280 ms 1.785 ms 17.089 ms 190.390 ms
ets 0.135 ms 0.879 ms 7.839 ms 61.522 ms
- version 0.2.x
-
- Write 10 100 1000 10000
- --------------------------------------------------
- pts 0.915 ms 6.116 ms 61.652 ms 610.025 ms
- ets 0.173 ms 1.059 ms 11.193 ms 121.168 ms
-
- Read 10 100 1000 10000
- --------------------------------------------------
- pts 0.216 ms 1.424 ms 16.051 ms 135.569 ms
- ets 0.081 ms 0.889 ms 8.038 ms 63.215 ms
pts is 6x times slow for write due to process spawn; and 2x times slow for
read.
View
@@ -888,8 +888,9 @@ AC_DEFUN([ACX_ERLANG],[
AC_SUBST(CONF2LIB)
erlang_path=$with_erlang:$with_erlang/bin:$PATH
- AC_PATH_PROG([ERLC], [erlc], [], [$erlang_path])
- AC_PATH_PROG([ERL], [erl], [], [$erlang_path])
+ AC_PATH_PROG([ERLC], [erlc], [], [$erlang_path])
+ AC_PATH_PROG([ERL], [erl], [], [$erlang_path])
+ AC_PATH_PROG([ESCRIPT],[escript], [], [$erlang_path])
if test "x$ERLC" == "x" ; then
AC_ERROR("Erlang runtime not found.")
@@ -907,6 +908,7 @@ AC_DEFUN([ACX_ERLANG],[
ACX_DEFINE_DIR([liberldir], $liberlroot, [])
ACX_DEFINE_DIR([pkgliberldir], $liberlroot, [$PACKAGE]-[$VERSION])
+ ACX_DEFINE_DIR([pkglibprivdir], $liberlroot, [$PACKAGE]-[$VERSION]/priv)
ACX_CHECK_ERLANG_LIB([erts])
@@ -1147,6 +1149,10 @@ ifndef ERL_CFLAGS
ERL_CFLAGS =
endif
+ifndef ERL_FLAGS
+ ERL_FLAGS =
+endif
+
ifeq (\$(BUILD),native)
ERL_CFLAGS += +native
endif
@@ -1156,6 +1162,11 @@ ifeq (\$(BUILD),debug)
endif
ERL_PATH = -pa ../*/ebin -pa ./*/ebin
+
+%%: %%.escript
+ \$(AM_V_ERL)\$(ESCRIPT) -s \$< && \
+ cp \$< \x24@ && \
+ chmod a+x \x24@
ebin/%%.beam : src/%%.erl
\$(AM_V_ERL)test -d ebin || mkdir ebin; \$(ERLC) \$(ERL_CFLAGS) -I ./include -b beam -o ebin \$<
@@ -1203,7 +1214,7 @@ debug:
\$(MAKE) BUILD=debug
run:
- \$(ERL) -pa ./ebin -pa ./*/ebin -pa ../*/ebin -pa ./priv -pa ../*/priv
+ \$(ERL) -pa ./ebin -pa ./*/ebin -pa ../*/ebin -pa ./priv -pa ../*/priv \$(ERL_FLAGS)
.force:
Oops, something went wrong.

0 comments on commit 89b8052

Please sign in to comment.