sync: mark sync.WaitGroup and sync.Mutex with [ref_only]
parent
7f69c2fbf5
commit
edb921f463
|
@ -4,14 +4,12 @@
|
||||||
module sync
|
module sync
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
fn C.pthread_mutex_init()
|
fn C.pthread_mutex_init(voidptr, voidptr) int
|
||||||
|
fn C.pthread_mutex_lock(voidptr) int
|
||||||
|
fn C.pthread_mutex_unlock(voidptr) int
|
||||||
|
|
||||||
|
|
||||||
fn C.pthread_mutex_lock()
|
|
||||||
|
|
||||||
|
|
||||||
fn C.pthread_mutex_unlock()
|
|
||||||
// [init_with=new_mutex] // TODO: implement support for this struct attribute, and disallow Mutex{} from outside the sync.new_mutex() function.
|
// [init_with=new_mutex] // TODO: implement support for this struct attribute, and disallow Mutex{} from outside the sync.new_mutex() function.
|
||||||
|
[ref_only]
|
||||||
pub struct Mutex {
|
pub struct Mutex {
|
||||||
mutex C.pthread_mutex_t
|
mutex C.pthread_mutex_t
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ module sync
|
||||||
type MHANDLE voidptr
|
type MHANDLE voidptr
|
||||||
|
|
||||||
//[init_with=new_mutex] // TODO: implement support for this struct attribute, and disallow Mutex{} from outside the sync.new_mutex() function.
|
//[init_with=new_mutex] // TODO: implement support for this struct attribute, and disallow Mutex{} from outside the sync.new_mutex() function.
|
||||||
|
|
||||||
|
[ref_only]
|
||||||
pub struct Mutex {
|
pub struct Mutex {
|
||||||
mut:
|
mut:
|
||||||
mx MHANDLE // mutex handle
|
mx MHANDLE // mutex handle
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
// Use of this source code is governed by an MIT license
|
// Use of this source code is governed by an MIT license
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
module sync
|
module sync
|
||||||
|
|
||||||
// [init_with=new_waitgroup] // TODO: implement support for init_with struct attribute, and disallow WaitGroup{} from outside the sync.new_waitgroup() function.
|
// [init_with=new_waitgroup] // TODO: implement support for init_with struct attribute, and disallow WaitGroup{} from outside the sync.new_waitgroup() function.
|
||||||
|
[ref_only]
|
||||||
pub struct WaitGroup {
|
pub struct WaitGroup {
|
||||||
mut:
|
mut:
|
||||||
mu &Mutex = &Mutex(0)
|
mu &Mutex = &Mutex(0)
|
||||||
|
|
Loading…
Reference in New Issue