~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to lib/dialyzer/test/race_SUITE_data/src/mnesia_diff_atoms_race1.erl

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%% This tests that the race condition detection between mnesia:dirty_read/
 
2
%% mnesia:dirty_write is robust even when the functions are called with
 
3
%% different atoms as arguments.
 
4
 
 
5
-module(mnesia_diff_atoms_race1).
 
6
-export([test/2]).
 
7
 
 
8
-record(employee, {emp_no,
 
9
                   name,
 
10
                   salary,
 
11
                   sex,
 
12
                   phone,
 
13
                   room_no}).
 
14
 
 
15
test(Eno, Raise) ->
 
16
  {race(employee, Eno, Raise), no_race(employee, Eno, Raise)}.
 
17
 
 
18
race(Tab, Eno, Raise) ->
 
19
    [E] = mnesia:dirty_read(Tab, Eno),
 
20
    Salary = E#employee.salary + Raise,
 
21
    New = E#employee{salary = Salary},
 
22
    aux(Tab, New).
 
23
 
 
24
no_race(Tab, Eno, Raise) ->
 
25
    [E] = mnesia:dirty_read(Tab, Eno),
 
26
    Salary = E#employee.salary + Raise,
 
27
    New = E#employee{salary = Salary},
 
28
    AnotherTab = employer,
 
29
    aux(AnotherTab, New).
 
30
 
 
31
 
 
32
aux(Table, Record) ->
 
33
  mnesia:dirty_write(Table, Record).