1
0
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:
Uwe Krüger
2020-07-04 12:44:25 +02:00
committed by GitHub
parent 27149ba8bc
commit 3b067f5f85
27 changed files with 510 additions and 51 deletions

View File

@ -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()

View File

@ -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)
}

View File

@ -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))

View File

@ -10,7 +10,7 @@ mut:
}
pub fn (mut w Waiter) wait() {
w.mx.lock()
w.mx.m_lock()
}
pub fn (mut w Waiter) stop() {

View File

@ -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()
}