[erlang-questions] Disallowing gen_server:handle_cast() for a while?
Attila Rajmund Nohl
attila.r.nohl@REDACTED
Thu Mar 3 16:02:20 CET 2011
2011/3/3, Koener Antoine <antoine.koener@REDACTED>:
>
> On Mar 3, 2011, at 10:57 , Attila Rajmund Nohl wrote:
>
>> 2011/3/2, Nav <orionqwest@REDACTED>:
>>> Hi,
>>>
>>> Is there a way to stop handle_cast(..) being called (i.e. stop
>>> gen_server from reading data from queue) for a while?
>>>
>>> I am trying to implement a logic, while processing, gen_server should
>>> not accept any messages and let messages stay in its queue. (Other
>>> processes can still send messages using gen_server:cast())
>>
>> Why not do this processing in a handle_info? Trigger the calling of
>> the handle_info call by sending a message to the gen_server.
>>
>
> Was thinking about something like this:
>
[...]
>
> handle_cast(_Any, #state{skip=true} = State) ->
> {noreply, State};
This way the "let messages stay in its queue" property would not hold,
because this clause would just throw away any messages received during
the "lock down" state.
More information about the erlang-questions
mailing list