summaryrefslogtreecommitdiff
path: root/src/fsyncport.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2014-10-27 01:24:09 +0100
committerMagnus Ahltorp <map@kth.se>2014-10-27 01:24:09 +0100
commit80ea2ac6af8f993888444a4f75bbcc976ddd3973 (patch)
tree8139e2346b6463f69b21c43c16de4705eb30226b /src/fsyncport.erl
parentdc8952f6fefc91e21bacf125f5414edf0d35db55 (diff)
Parallel fsync
Diffstat (limited to 'src/fsyncport.erl')
-rw-r--r--src/fsyncport.erl22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/fsyncport.erl b/src/fsyncport.erl
index 5084fdd..c9be44d 100644
--- a/src/fsyncport.erl
+++ b/src/fsyncport.erl
@@ -3,7 +3,7 @@
-module(fsyncport).
-export([start_link/0, stop/0, init/1]).
--export([fsync/1]).
+-export([fsync/1, fsyncall/1]).
start_link() ->
Pid = spawn(?MODULE, init, [code:priv_dir(plop) ++ "/fsynchelper"]),
@@ -14,6 +14,9 @@ stop() ->
fsync(Path) ->
call_port({fsync, Path}).
+fsyncall(Paths) ->
+ call_port_multi([{fsync, Path} || Path <- Paths]).
+
call_port(Msg) ->
fsyncport ! {call, self(), Msg},
receive
@@ -21,6 +24,23 @@ call_port(Msg) ->
Result
end.
+call_port_multi(Msgs) ->
+ lists:foreach(fun (Msg) ->
+ fsyncport ! {call, self(), Msg}
+ end, Msgs),
+ lists:foldl(fun (_Msg, Acc) ->
+ R = receive
+ {fsyncport, Result} ->
+ Result
+ end,
+ case R of
+ ok ->
+ Acc;
+ Error ->
+ Error
+ end
+ end, ok, Msgs).
+
init(ExtPrg) ->
lager:debug("starting fsync service"),
register(fsyncport, self()),