summaryrefslogtreecommitdiff
path: root/man/2/lock
blob: ff9a0fa783f2b4d87118faf62fc98dcc06e79ecd (plain)
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
.TH LOCK 2
.SH NAME
lock \-
thread locking.
.SH SYNOPSIS
.EX
include "lock.m";
lock := load Lock Lock->PATH;
Semaphore: adt {
	c: chan of int;
	obtain: fn(s: self ref Semaphore);
	release: fn(s: self ref Semaphore);
	new: fn(): ref Semaphore;
};
init: fn();
.EE
.SH DESCRIPTION
.B Lock
provides semaphore-based mutual exclusion.
.B Init
must be called before creating any locks.
.TP
.B Semaphore.new()
Creates and returns a reference to a new
.B Semaphore
(lock).
.TP
.IB s .obtain()
Obtains exclusive access to the lock
.IR s .
It will block until it can do so.
.TP
.IB s .release()
Releases access to the lock
.I s
and allows processes waiting on it to proceed.
.SH SOURCE
.B /appl/lib/lock.b