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

sync: make new_mutex() and new_waitgroup() return &Mutex and &Waitgroup

This commit is contained in:
Delyan Angelov
2020-01-19 21:32:22 +02:00
committed by Alexander Medvednikov
parent bc64263dd8
commit 0d52cc97e4
5 changed files with 12 additions and 20 deletions

View File

@@ -5,15 +5,12 @@ module sync
// [init_with=new_waitgroup] // TODO: implement support for init_with struct attribute, and disallow WaitGroup{} from outside the sync.new_waitgroup() function.
pub struct WaitGroup {
mut:
mu Mutex
mu &Mutex = &Mutex(0)
active int
}
pub fn new_waitgroup() WaitGroup {
mut w := WaitGroup{
}
w.mu = sync.new_mutex()
return w
pub fn new_waitgroup() &WaitGroup {
return &WaitGroup{mu: sync.new_mutex() }
}
pub fn (wg mut WaitGroup) add(delta int) {