[erlang-questions] Deterministic playback of a simulation?

Ulf Wiger ulf@REDACTED
Fri May 18 13:38:05 CEST 2012

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.

Ulf W

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.

More information about the erlang-questions mailing list