Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Mutex/Tcl/mutex-1.tcl
Normal file
13
Task/Mutex/Tcl/mutex-1.tcl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package require Thread
|
||||
|
||||
# How to create a mutex
|
||||
set m [thread::mutex create]
|
||||
|
||||
# This will block if the lock is already held unless the mutex is made recursive
|
||||
thread::mutex lock $m
|
||||
# Now locked...
|
||||
thread::mutex unlock $m
|
||||
# Unlocked again
|
||||
|
||||
# Dispose of the mutex
|
||||
thread::mutex destroy $m
|
||||
11
Task/Mutex/Tcl/mutex-2.tcl
Normal file
11
Task/Mutex/Tcl/mutex-2.tcl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
set rw [thread::rwmutex create]
|
||||
|
||||
# Get and drop a reader lock
|
||||
thread::rwmutex rlock $rw
|
||||
thread::rwmutex unlock $rw
|
||||
|
||||
# Get and drop a writer lock
|
||||
thread::rwmutex wlock $rw
|
||||
thread::rwmutex unlock $rw
|
||||
|
||||
thread::rwmutex destroy $rw
|
||||
Loading…
Add table
Add a link
Reference in a new issue