diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2012-01-24 18:11:01 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2012-01-24 18:11:01 +0000 |
commit | 030aa84b31573804c392571d9febd3db483b361f (patch) | |
tree | c20714295d687b0be085e1263953b5043b6fc31d /src/credit_flow.erl | |
parent | 7185a880f04f47df4d484a73af7e2e42852bc7d4 (diff) | |
download | rabbitmq-server-030aa84b31573804c392571d9febd3db483b361f.tar.gz |
Remove ?CREDIT_CPU_BOUND and have /1 versions of ack and send instead.bug24671
Diffstat (limited to 'src/credit_flow.erl')
-rw-r--r-- | src/credit_flow.erl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/credit_flow.erl b/src/credit_flow.erl index cfafd920..397aa191 100644 --- a/src/credit_flow.erl +++ b/src/credit_flow.erl @@ -25,7 +25,9 @@ %% senders when it is itself blocked - thus the only processes that %% need to check blocked/0 are ones that read from network sockets. --export([ack/2, handle_bump_msg/1, blocked/0, send/2]). +-define(DEFAULT_CREDIT, {200, 150}). + +-export([ack/1, ack/2, handle_bump_msg/1, blocked/0, send/1, send/2]). -export([peer_down/1]). %%---------------------------------------------------------------------------- @@ -35,9 +37,11 @@ -opaque(bump_msg() :: {pid(), non_neg_integer()}). -opaque(credit_spec() :: {non_neg_integer(), non_neg_integer()}). +-spec(ack/1 :: (pid()) -> 'ok'). -spec(ack/2 :: (pid(), credit_spec()) -> 'ok'). -spec(handle_bump_msg/1 :: (bump_msg()) -> 'ok'). -spec(blocked/0 :: () -> boolean()). +-spec(send/1 :: (pid()) -> 'ok'). -spec(send/2 :: (pid(), credit_spec()) -> 'ok'). -spec(peer_down/1 :: (pid()) -> 'ok'). @@ -56,6 +60,8 @@ %% For any given pair of processes, ack/2 and send/2 must always be %% called with the same credit_spec(). +ack(To) -> ack(To, ?DEFAULT_CREDIT). + ack(To, {MaxCredit, MoreCreditAt}) -> MoreCreditAt1 = MoreCreditAt + 1, Credit = @@ -78,6 +84,8 @@ handle_bump_msg({From, MoreCredit}) -> blocked() -> get(credit_blocked, []) =/= []. +send(From) -> send(From, ?DEFAULT_CREDIT). + send(From, {MaxCredit, _MoreCreditAt}) -> Credit = get({credit_from, From}, MaxCredit) - 1, case Credit of |