mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: experimental locked concurrency support, part 1 (#5637)
This commit is contained in:
@ -139,7 +139,7 @@ fn process_in_thread(mut pool PoolProcessor, task_id int) {
|
||||
if pool.ntask >= ilen {
|
||||
break
|
||||
}
|
||||
pool.ntask_mtx.lock()
|
||||
pool.ntask_mtx.m_lock()
|
||||
idx = pool.ntask
|
||||
pool.ntask++
|
||||
pool.ntask_mtx.unlock()
|
||||
|
@ -17,7 +17,8 @@ pub fn new_mutex() &Mutex {
|
||||
return m
|
||||
}
|
||||
|
||||
pub fn (mut m Mutex) lock() {
|
||||
// m_lock(), for *manual* mutex handling, since `lock` is a keyword
|
||||
pub fn (mut m Mutex) m_lock() {
|
||||
C.pthread_mutex_lock(&m.mutex)
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ pub fn new_mutex() &Mutex {
|
||||
return sm
|
||||
}
|
||||
|
||||
pub fn (mut m Mutex) lock() {
|
||||
pub fn (mut m Mutex) m_lock() {
|
||||
// if mutex handle not initalized
|
||||
if isnil(m.mx) {
|
||||
m.mx = MHANDLE(C.CreateMutex(0, false, 0))
|
||||
|
@ -10,7 +10,7 @@ mut:
|
||||
}
|
||||
|
||||
pub fn (mut w Waiter) wait() {
|
||||
w.mx.lock()
|
||||
w.mx.m_lock()
|
||||
}
|
||||
|
||||
pub fn (mut w Waiter) stop() {
|
||||
|
@ -30,7 +30,7 @@ pub fn new_waitgroup() &WaitGroup {
|
||||
// add panics if task count drops below zero.
|
||||
pub fn (mut wg WaitGroup) add(delta int) {
|
||||
// protect task_count
|
||||
wg.task_count_mutex.lock()
|
||||
wg.task_count_mutex.m_lock()
|
||||
defer {
|
||||
wg.task_count_mutex.unlock()
|
||||
}
|
||||
|
Reference in New Issue
Block a user