aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-03-22 09:46:23 +0100
committerBjörn Gustavsson <[email protected]>2013-05-31 14:52:22 +0200
commit6f9ebc3237cf62fb550c9417569ca78c79865b91 (patch)
tree97801739d0614620f1834ec013775092e21216cc /lib/asn1
parentf5e68a7e844f491497d5363ce5bf8b5362ec387b (diff)
downloadotp-6f9ebc3237cf62fb550c9417569ca78c79865b91.tar.gz
otp-6f9ebc3237cf62fb550c9417569ca78c79865b91.tar.bz2
otp-6f9ebc3237cf62fb550c9417569ca78c79865b91.zip
asn1_db: Make dbput/3 and dbsave/2 asynchronous
Those functions have no reason to be synchronous since they don't have a useful return value.
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/src/asn1_db.erl15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/asn1/src/asn1_db.erl b/lib/asn1/src/asn1_db.erl
index 7ea29b7021..e96ca9ae25 100644
--- a/lib/asn1/src/asn1_db.erl
+++ b/lib/asn1/src/asn1_db.erl
@@ -32,8 +32,8 @@ dbstart(Includes) ->
ok.
dbnew(Module) -> req({new, Module}).
-dbsave(OutFile, Module) -> req({save, OutFile, Module}).
-dbput(Module, K, V) -> req({set, Module, K, V}).
+dbsave(OutFile, Module) -> cast({save, OutFile, Module}).
+dbput(Module, K, V) -> cast({set, Module, K, V}).
dbget(Module, K) -> req({get, Module, K}).
dbstop() -> Resp = req(stop), erase(?MODULE), Resp.
@@ -50,6 +50,10 @@ req(Request) ->
exit({db_error,Info})
end.
+cast(Request) ->
+ get(?MODULE) ! Request,
+ ok.
+
reply({Ref,From}, Response) ->
From ! {{Ref,?MODULE}, Response},
ok.
@@ -62,10 +66,9 @@ init(Parent, Includes) ->
loop(#state{parent = Parent, monitor = MRef, table = Table,
includes = Includes} = State) ->
receive
- {From, {set, Mod, K2, V}} ->
+ {set, Mod, K2, V} ->
[{_, Modtab}] = ets:lookup(Table, Mod),
ets:insert(Modtab, {K2, V}),
- reply(From, ok),
loop(State);
{From, {get, Mod, K2}} ->
Result = case ets:lookup(Table, Mod) of
@@ -77,9 +80,9 @@ loop(#state{parent = Parent, monitor = MRef, table = Table,
_Error -> reply(From, undefined)
end,
loop(State);
- {From, {save, OutFile, Mod}} ->
+ {save, OutFile, Mod} ->
[{_,Mtab}] = ets:lookup(Table, Mod),
- reply(From, ets:tab2file(Mtab, OutFile)),
+ ok = ets:tab2file(Mtab, OutFile),
loop(State);
{From, {new, Mod}} ->
[] = ets:lookup(Table, Mod), %Assertion.