21
21
# acquire the lock will block until the element is put back into the container:
22
22
23
23
acquiring (l:: SimpleLock ) = taking (l. access)
24
- realeasing (l:: SimpleLock ) = Return (nothing ) ⨟ putting (l. access)
24
+ releasing (l:: SimpleLock ) = Return (nothing ) ⨟ putting (l. access)
25
25
26
26
Base. lock (l:: SimpleLock ) = acquiring (l)()
27
- Base. unlock (l:: SimpleLock ) = realeasing (l)()
27
+ Base. unlock (l:: SimpleLock ) = releasing (l)()
28
28
29
29
# Thus, when creating a lock with an empty container, it is in the locked state.
30
30
# We need to unlock it (i.e., put one element in the container) before start
@@ -204,10 +204,10 @@ function SimpleSemaphore(n::Integer)
204
204
end
205
205
206
206
acquiring (l:: SimpleSemaphore ) = taking (l. accesses)
207
- realeasing (l:: SimpleSemaphore ) = Return (nothing ) ⨟ putting (l. accesses)
207
+ releasing (l:: SimpleSemaphore ) = Return (nothing ) ⨟ putting (l. accesses)
208
208
209
209
Base. acquire (l:: SimpleSemaphore ) = acquiring (l)()
210
- Base. release (l:: SimpleSemaphore ) = realeasing (l)()
210
+ Base. release (l:: SimpleSemaphore ) = releasing (l)()
211
211
212
212
# Unlike `SimpleLock`, we can acquire `SimpleSemaphore(n)` `n` times before
213
213
# blocked:
@@ -238,13 +238,13 @@ struct ChLock <: Base.AbstractLock
238
238
end
239
239
240
240
acquiring (l:: ChLock ) = l. acq
241
- realeasing (l:: ChLock ) = l. rel
241
+ releasing (l:: ChLock ) = l. rel
242
242
243
243
Base. lock (l:: ChLock ) = acquiring (l)()
244
- Base. unlock (l:: ChLock ) = realeasing (l)()
244
+ Base. unlock (l:: ChLock ) = releasing (l)()
245
245
246
246
# To create two kinds of locks, we create `2 * 2 = 4` channels. The state of
247
- # the lock is mantained by two blocking data structures (Note: We only need to
247
+ # the lock is maintained by two blocking data structures (Note: We only need to
248
248
# store at most one element. So, a stack is an overkill. But that's the most
249
249
# cheap data structure we have implemented so far in the tutorial):
250
250
@@ -323,7 +323,7 @@ function test_reader_writer_lock()
323
323
sleep (0.1 )
324
324
@test ! wlocked[]
325
325
end
326
- @test r2 () === r2 () === :done # releaseing `rlock`
326
+ @test r2 () === r2 () === :done # releasing `rlock`
327
327
@test r1 () == 3
328
328
@test wlocked[]
329
329
@@ -350,10 +350,10 @@ function test_reader_writer_lock()
350
350
sleep (0.1 )
351
351
@test r4locked[] == r5locked[] == false
352
352
end
353
- @test r2 () === :done # releaseing `wlock`
353
+ @test r2 () === :done # releasing `wlock`
354
354
@test sort! ([r1 (), r1 ()]) == [4 , 5 ]
355
355
@test r4locked[] == r5locked[] == true
356
- @test r2 () === r2 () === :done # releaseing `rlock`
356
+ @test r2 () === r2 () === :done # releasing `rlock`
357
357
end
358
358
end
359
359
0 commit comments