summaryrefslogtreecommitdiff
path: root/locking
blob: edf2040fb3ea5aecd088b61e07ff3409d1c92dc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Locking is hard

A possible design:
	- Every object has its own lock
	- No more than one lock can be taken by the same
	  thread at a time.

+ Is a checkable invariant. A wrapper around g_mutex_lock() can be
  written that checks it.

- Draconican Rules:
	- whenever you call a callback or a method on another object:

		- first make a copy of all the state yuo wish to pass
		- then unlock
		- then call and store the return value on the stack
		- then lock
		- then do something with the return value.

		And at this point be aware that other threads could
		have changed you.