mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
23 lines
391 B
V
23 lines
391 B
V
|
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
|
||
|
// Use of this source code is governed by an MIT license
|
||
|
// that can be found in the LICENSE file.
|
||
|
module sync
|
||
|
|
||
|
[ref_only]
|
||
|
struct Waiter{
|
||
|
mut:
|
||
|
mx &Mutex
|
||
|
}
|
||
|
|
||
|
pub fn (mut w Waiter) wait() {
|
||
|
w.mx.lock()
|
||
|
}
|
||
|
|
||
|
pub fn (mut w Waiter) stop() {
|
||
|
w.mx.unlock()
|
||
|
}
|
||
|
pub fn new_waiter() &Waiter {
|
||
|
w := &Waiter{mx: new_mutex()}
|
||
|
return w
|
||
|
}
|