mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: check (mut f Foo)
syntax
This commit is contained in:
@ -86,7 +86,7 @@ pub fn new_pool_processor(context PoolProcessorConfig) &PoolProcessor {
|
||||
|
||||
// set_max_jobs gives you the ability to override the number
|
||||
// of jobs *after* the PoolProcessor had been created already.
|
||||
pub fn (pool mut PoolProcessor) set_max_jobs(njobs int) {
|
||||
pub fn (mut pool PoolProcessor) set_max_jobs(njobs int) {
|
||||
pool.njobs = njobs
|
||||
}
|
||||
|
||||
@ -99,11 +99,11 @@ pub fn (pool mut PoolProcessor) set_max_jobs(njobs int) {
|
||||
// work_on_items returns *after* all threads finish.
|
||||
// You can optionally call get_results after that.
|
||||
// TODO: uncomment, when generics work again
|
||||
//pub fn (pool mut PoolProcessor) work_on_items<T>(items []T) {
|
||||
//pub fn (mut pool PoolProcessor) work_on_items<T>(items []T) {
|
||||
// pool.work_on_pointers( items.pointers() )
|
||||
//}
|
||||
|
||||
pub fn (pool mut PoolProcessor) work_on_pointers(items []voidptr) {
|
||||
pub fn (mut pool PoolProcessor) work_on_pointers(items []voidptr) {
|
||||
mut njobs := runtime.nr_jobs()
|
||||
if pool.njobs > 0 {
|
||||
njobs = pool.njobs
|
||||
@ -186,7 +186,7 @@ pub fn (pool &PoolProcessor) get_int_item(idx int) int {
|
||||
// set_shared_context - can be called during the setup so that you can
|
||||
// provide a context that is shared between all worker threads, like
|
||||
// common options/settings.
|
||||
pub fn (pool mut PoolProcessor) set_shared_context(context voidptr) {
|
||||
pub fn (mut pool PoolProcessor) set_shared_context(context voidptr) {
|
||||
pool.shared_context = context
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ pub fn (pool &PoolProcessor) get_shared_context() voidptr {
|
||||
// local storage area where it can write/read information that is private
|
||||
// to the given thread, without worrying that it will get overwritten by
|
||||
// another thread
|
||||
pub fn (pool mut PoolProcessor) set_thread_context(idx int, context voidptr) {
|
||||
pub fn (mut pool PoolProcessor) set_thread_context(idx int, context voidptr) {
|
||||
pool.thread_contexts[idx] = context
|
||||
}
|
||||
|
||||
@ -223,11 +223,11 @@ pub:
|
||||
|
||||
//
|
||||
|
||||
pub fn (pool mut PoolProcessor) work_on_items_s(items []string) {
|
||||
pub fn (mut pool PoolProcessor) work_on_items_s(items []string) {
|
||||
pool.work_on_pointers( items.pointers() )
|
||||
}
|
||||
|
||||
pub fn (pool mut PoolProcessor) work_on_items_i(items []int) {
|
||||
pub fn (mut pool PoolProcessor) work_on_items_i(items []int) {
|
||||
pool.work_on_pointers( items.pointers() )
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,10 @@ pub fn new_mutex() &Mutex {
|
||||
return m
|
||||
}
|
||||
|
||||
pub fn (m mut Mutex) lock() {
|
||||
pub fn (mut m Mutex) lock() {
|
||||
C.pthread_mutex_lock(&m.mutex)
|
||||
}
|
||||
|
||||
pub fn (m mut Mutex) unlock() {
|
||||
pub fn (mut m Mutex) unlock() {
|
||||
C.pthread_mutex_unlock(&m.mutex)
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ pub fn new_mutex() &Mutex {
|
||||
return sm
|
||||
}
|
||||
|
||||
pub fn (m mut Mutex) lock() {
|
||||
pub fn (mut m Mutex) lock() {
|
||||
// if mutex handle not initalized
|
||||
if isnil(m.mx) {
|
||||
m.mx = C.CreateMutex(0, false, 0)
|
||||
@ -68,7 +68,7 @@ pub fn (m mut Mutex) lock() {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (m mut Mutex) unlock() {
|
||||
pub fn (mut m Mutex) unlock() {
|
||||
if m.state == .waiting {
|
||||
if C.ReleaseMutex(m.mx) {
|
||||
m.state = .broken
|
||||
@ -78,7 +78,7 @@ pub fn (m mut Mutex) unlock() {
|
||||
m.state = .released
|
||||
}
|
||||
|
||||
pub fn (m mut Mutex) destroy() {
|
||||
pub fn (mut m Mutex) destroy() {
|
||||
if m.state == .waiting {
|
||||
m.unlock() // unlock mutex before destroying
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ pub fn new_waitgroup() &WaitGroup {
|
||||
return &WaitGroup{mu: sync.new_mutex() }
|
||||
}
|
||||
|
||||
pub fn (wg mut WaitGroup) add(delta int) {
|
||||
pub fn (mut wg WaitGroup) add(delta int) {
|
||||
wg.mu.lock()
|
||||
wg.active += delta
|
||||
wg.mu.unlock()
|
||||
@ -24,7 +24,7 @@ pub fn (wg mut WaitGroup) add(delta int) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (wg mut WaitGroup) done() {
|
||||
pub fn (mut wg WaitGroup) done() {
|
||||
wg.add(-1)
|
||||
}
|
||||
|
||||
@ -39,4 +39,3 @@ pub fn (wg &WaitGroup) wait() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user