summaryrefslogtreecommitdiff
path: root/lib/dialyzer/test/race_SUITE_data/src/whereis_diff_functions2_nested.erl
blob: 5ae8784389e4a042b7f2e43a218944c41c824c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
%% This tests that the race condition detection between whereis/register
%% is robust w.r.t. having the calls in separate functions.

-module(whereis_diff_functions2_nested).
-export([start/2]).

start(AnAtom, Fun) ->
  case whereis(AnAtom) of
    undefined ->
      Pid = spawn(Fun),
      race1(AnAtom, Pid);
    P when is_pid(P) ->
      true
  end.

race1(Atom, Pid) ->
  race2(Atom, Pid).

race2(Atom, Pid) ->
  register(Atom, Pid).