summaryrefslogtreecommitdiff
path: root/lib/dialyzer/test/race_SUITE_data/src/mnesia_dirty_read_two_write_one.erl
blob: e523a03789b5f41ed64ff409af477ae4cd17d952 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
%% This tests the presence of possible races due to an mnesia:dirty_read/
%% mnesia:dirty_write combination. It takes into account the argument types
%% of the calls.

-module(mnesia_dirty_read_two_write_one).
-export([raise/2]).

-record(employee, {emp_no,
                   name,
                   salary,
                   sex,
                   phone,
                   room_no}).


raise(Eno, Raise) ->
    [E] = mnesia:dirty_read(employee, Eno),
    Salary = E#employee.salary + Raise,
    New = E#employee{salary = Salary},
    mnesia:dirty_write(New).