[erlang-questions] Deterministic playback of a simulation?

Richard Evans richardprideauxevans@REDACTED
Fri May 18 18:30:00 CEST 2012


Thanks guys for all your helpful responses :)

On Fri, May 18, 2012 at 12:38 PM, Ulf Wiger <ulf@REDACTED> wrote:
>
> On 18 May 2012, at 04:36, Richard Evans wrote:
>
>> So my question is: is there a way to prevent the scheduler from
>> yielding during a block of code? Some way to insist the block is
>> called as one unit, like this:
>>
>> call_and_store(Fun, Args) ->
>>       !!!prevent_yielding,
>>    add_to_script(Fun, Args);
>>    apply(lobby, Fun, Args),
>>       !!!allow_yielding.
>>
>> My guess is: no. This does not seem very erlangy.
>
> No, not at that level.
>
> But you could use e.g.
>
>  global:trans({call_and_store, self()}, fun() -> call_and_store(Fun, Args) end).
>
> See erl -man global
>
> You can specify on how many nodes you want to acquire a lock - default is all connected nodes, but you can set it e.g. to [node()] if that suits you better.
>
> BR,
> Ulf W
>
> Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
> http://feuerlabs.com
>
>
>



More information about the erlang-questions mailing list