summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Joubert <emile@rabbitmq.com>2011-01-10 14:36:47 +0000
committerEmile Joubert <emile@rabbitmq.com>2011-01-10 14:36:47 +0000
commitc916d953626e1c8acb3cd74a8dfc08ef0a0c9e28 (patch)
tree0d44cde70958612bdf04d94184ffb0a1b8394b27
parent831b609b58447daa4e40b192c836a6ecf92f896a (diff)
downloadrabbitmq-server-c916d953626e1c8acb3cd74a8dfc08ef0a0c9e28.tar.gz
More frugal use of thunks
-rw-r--r--src/rabbit_amqqueue.erl7
-rw-r--r--src/rabbit_misc.erl4
2 files changed, 7 insertions, 4 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index 82c1f454..ba8ce6da 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -213,14 +213,13 @@ declare(QueueName, Durable, AutoDelete, Args, Owner) ->
end.
internal_declare(Q = #amqqueue{name = QueueName}, Recover) ->
- EmptyFun = fun (_) -> ok end,
rabbit_misc:execute_mnesia_tx_with_tail(
fun () ->
{ReturnArg, TailFun} =
case Recover of
true ->
ok = store_queue(Q),
- {Q, EmptyFun};
+ {Q, fun rabbit_misc:const_ok/1};
false ->
case mnesia:wread({rabbit_queue, QueueName}) of
[] ->
@@ -230,10 +229,10 @@ internal_declare(Q = #amqqueue{name = QueueName}, Recover) ->
B = add_default_binding(Q),
{Q, B};
%% Q exists on stopped node
- [_] -> {not_found, EmptyFun}
+ [_] -> {not_found, fun rabbit_misc:const_ok/1}
end;
[ExistingQ] ->
- {ExistingQ, EmptyFun}
+ {ExistingQ, fun rabbit_misc:const_ok/1}
end
end,
fun (Tx) ->
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index f0221e56..133d2a6c 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -70,6 +70,7 @@
-export([all_module_attributes/1, build_acyclic_graph/3]).
-export([now_ms/0]).
-export([lock_file/1]).
+-export([const_ok/1]).
%%----------------------------------------------------------------------------
@@ -205,6 +206,7 @@
digraph:vertex(), digraph:vertex()})).
-spec(now_ms/0 :: () -> non_neg_integer()).
-spec(lock_file/1 :: (file:filename()) -> rabbit_types:ok_or_error('eexist')).
+-spec(const_ok/1 :: (any()) -> 'ok').
-endif.
@@ -853,3 +855,5 @@ lock_file(Path) ->
false -> {ok, Lock} = file:open(Path, [write]),
ok = file:close(Lock)
end.
+
+const_ok(_) -> ok.