1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

sync: add Mutex.destroy and RwMutex.destroy methods (#18351)

This commit is contained in:
kbkpbot
2023-06-06 19:45:12 +08:00
committed by GitHub
parent c1e302a38d
commit 632c466aa0
2 changed files with 60 additions and 4 deletions

View File

@@ -0,0 +1,20 @@
import sync
fn main() {
mut mutex := sync.new_mutex()
mutex.@lock()
mutex.unlock()
mutex.destroy()
mut rwmutex := sync.new_rwmutex()
rwmutex.@rlock()
rwmutex.unlock()
rwmutex.@lock()
rwmutex.unlock()
rwmutex.destroy()
mut sem := sync.new_semaphore()
sem.post()
sem.wait()
sem.destroy()
}