-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathatomic.html
78 lines (78 loc) · 2.81 KB
/
atomic.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<html dir="ltr">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<title>Arc: Atomic operations</title>
<link rel="shortcut icon" href="/assets/favicon.png">
<link rel="stylesheet" type="text/css" href="code.css">
<link href="/assets/bootstrap.css" rel="stylesheet">
</head>
<body style='margin:12px 50px 0'>
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<ul class="nav navbar-nav">
<li><a href="/ref/">Arc 3.1</a>
<li><a href="http://tryarc.org">Try it</a></li>
<li><a href="http://github.com/arclanguage/anarki">Get it</a></li>
<li><a href="http://ycombinator.com/arc/tut.txt">Tutorial</a></li>
<li><a href="http://arclanguage.org/forum">Forum</a></li>
</ul>
</div>
</div> <!-- end of navbar -->
<div class="links">Previous: <a href="networking.html">Networking</a>
Up: <a href="index.html">Contents</a>
Next: <a href="os.html">Operating system</a>
</div>
<h1 class="links">Atomic operations</h1>
Atomic operations
<h2>Atomic operations</h2>
<p><table class='arc'>
<tr>
<td class='arc'><a name='atomic-invoke'></a>
<img src='foundation.gif' title='Foundation'/>
<span class='op'>atomic-invoke</span> <span class='args'>function</span>
<div class='desc'>Invokes function, making sure that only one
thread at a time invokes something wrapped inside an atomic-invoke.</div>
</td>
<td class='arc'><pre>
>(atomic-invoke (fn () "critical section" (+ 1 2)))
<span class="return">3
</span></pre>
</td></tr>
<tr>
<td class='arc'><a name='atomic'></a>
<img src='macro.gif' title='Macro'/>
<span class='op'>atomic</span> <span class='args'>[body ...]</span>
<div class='desc'>Executes the body statements atomically. The body is wrapped in <code>atomic-invoke</code> to ensure that only one such body can execute at a time.</div>
</td>
<td class='arc'><pre>
>(atomic (pr "hello"))
<span class="stdout">hello
</span><span class="return">"hello"
</span></pre>
</td></tr>
<tr>
<td class='arc'><a name='atlet'></a>
<img src='macro.gif' title='Macro'/>
<span class='op'>atlet</span> <span class='args'>var value [body ...]</span>
<div class='desc'>Atomic version of <code>let</code>. The value is assigned to var, and the body is executed, all inside <code>atomic</code>. </div>
</td>
<td class='arc'> </td></tr>
<tr>
<td class='arc'><a name='atwith'></a>
<img src='macro.gif' title='Macro'/>
<span class='op'>atwith</span> <span class='args'>args</span>
<div class='desc'></div>
</td>
<td class='arc'> </td></tr>
<tr>
<td class='arc'><a name='atwiths'></a>
<img src='macro.gif' title='Macro'/>
<span class='op'>atwiths</span> <span class='args'>args</span>
<div class='desc'></div>
</td>
<td class='arc'> </td></tr>
</table>
<p>
Copyright 2008 Ken Shirriff.
</body>
</html>