sync: rename `m_lock() -> @lock()`, `r_lock() -> @rlock()`, ... (#8443)

pull/8447/head
Uwe Krüger 2021-01-30 15:23:55 +01:00 committed by GitHub
parent 8dff63b824
commit 058f3ba013
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 32 deletions

View File

@ -210,7 +210,7 @@ fn (mut cb Clipboard) free() {
}
fn (mut cb Clipboard) clear() {
cb.mutex.m_lock()
cb.mutex.@lock()
C.XSetSelectionOwner(cb.display, cb.selection, C.Window(C.None), C.CurrentTime)
C.XFlush(cb.display)
cb.is_owner = false
@ -232,7 +232,7 @@ pub fn (mut cb Clipboard) set_text(text string) bool {
if cb.window == C.Window(C.None) {
return false
}
cb.mutex.m_lock()
cb.mutex.@lock()
cb.text = text
cb.is_owner = true
cb.take_ownership()
@ -276,7 +276,7 @@ fn (mut cb Clipboard) transmit_selection(xse &C.XSelectionEvent) bool {
C.XChangeProperty(xse.display, xse.requestor, xse.property, cb.get_atom(.xa_atom),
32, C.PropModeReplace, targets.data, targets.len)
} else if cb.is_supported_target(xse.target) && cb.is_owner && cb.text != '' {
cb.mutex.m_lock()
cb.mutex.@lock()
C.XChangeProperty(xse.display, xse.requestor, xse.property, xse.target, 8, C.PropModeReplace,
cb.text.str, cb.text.len)
cb.mutex.unlock()
@ -308,7 +308,7 @@ fn (mut cb Clipboard) start_listener() {
event.xselectionclear.selection == cb.selection
}
{
cb.mutex.m_lock()
cb.mutex.@lock()
cb.is_owner = false
cb.text = ''
cb.mutex.unlock()
@ -353,7 +353,7 @@ fn (mut cb Clipboard) start_listener() {
} else if unsafe { event.xselection.target == to_be_requested } {
sent_request = false
to_be_requested = C.Atom(0)
cb.mutex.m_lock()
cb.mutex.@lock()
prop := unsafe {
read_property(event.xselection.display, event.xselection.requestor,
event.xselection.property)

View File

@ -139,7 +139,7 @@ fn process_in_thread(mut pool PoolProcessor, task_id int) {
if pool.ntask >= ilen {
break
}
pool.ntask_mtx.m_lock()
pool.ntask_mtx.@lock()
idx = pool.ntask
pool.ntask++
pool.ntask_mtx.unlock()

View File

@ -69,8 +69,8 @@ pub fn (mut m RwMutex) init() {
C.pthread_rwlock_init(&m.mutex, &a.attr)
}
// m_lock(), for *manual* mutex handling, since `lock` is a keyword
pub fn (mut m Mutex) m_lock() {
// @lock(), for *manual* mutex handling, since `lock` is a keyword
pub fn (mut m Mutex) @lock() {
C.pthread_mutex_lock(&m.mutex)
}
@ -79,21 +79,21 @@ pub fn (mut m Mutex) unlock() {
}
// RwMutex has separate read- and write locks
pub fn (mut m RwMutex) r_lock() {
pub fn (mut m RwMutex) @rlock() {
C.pthread_rwlock_rdlock(&m.mutex)
}
pub fn (mut m RwMutex) w_lock() {
pub fn (mut m RwMutex) @lock() {
C.pthread_rwlock_wrlock(&m.mutex)
}
// Windows SRWLocks have different function to unlock
// So provide two functions here, too, to have a common interface
pub fn (mut m RwMutex) r_unlock() {
pub fn (mut m RwMutex) runlock() {
C.pthread_rwlock_unlock(&m.mutex)
}
pub fn (mut m RwMutex) w_unlock() {
pub fn (mut m RwMutex) unlock() {
C.pthread_rwlock_unlock(&m.mutex)
}

View File

@ -80,8 +80,8 @@ pub fn (mut m RwMutex) init() {
C.pthread_rwlock_init(&m.mutex, &a.attr)
}
// m_lock(), for *manual* mutex handling, since `lock` is a keyword
pub fn (mut m Mutex) m_lock() {
// @lock(), for *manual* mutex handling, since `lock` is a keyword
pub fn (mut m Mutex) @lock() {
C.pthread_mutex_lock(&m.mutex)
}
@ -90,21 +90,21 @@ pub fn (mut m Mutex) unlock() {
}
// RwMutex has separate read- and write locks
pub fn (mut m RwMutex) r_lock() {
pub fn (mut m RwMutex) @rlock() {
C.pthread_rwlock_rdlock(&m.mutex)
}
pub fn (mut m RwMutex) w_lock() {
pub fn (mut m RwMutex) @lock() {
C.pthread_rwlock_wrlock(&m.mutex)
}
// Windows SRWLocks have different function to unlock
// So provide two functions here, too, to have a common interface
pub fn (mut m RwMutex) r_unlock() {
pub fn (mut m RwMutex) runlock() {
C.pthread_rwlock_unlock(&m.mutex)
}
pub fn (mut m RwMutex) w_unlock() {
pub fn (mut m RwMutex) unlock() {
C.pthread_rwlock_unlock(&m.mutex)
}

View File

@ -57,7 +57,7 @@ pub fn (mut m RwMutex) init() {
C.InitializeSRWLock(&m.mx)
}
pub fn (mut m Mutex) m_lock() {
pub fn (mut m Mutex) @lock() {
C.AcquireSRWLockExclusive(&m.mx)
}
@ -66,21 +66,21 @@ pub fn (mut m Mutex) unlock() {
}
// RwMutex has separate read- and write locks
pub fn (mut m RwMutex) r_lock() {
pub fn (mut m RwMutex) @rlock() {
C.AcquireSRWLockShared(&m.mx)
}
pub fn (mut m RwMutex) w_lock() {
pub fn (mut m RwMutex) @lock() {
C.AcquireSRWLockExclusive(&m.mx)
}
// Windows SRWLocks have different function to unlock
// So provide two functions here, too, to have a common interface
pub fn (mut m RwMutex) r_unlock() {
pub fn (mut m RwMutex) runlock() {
C.ReleaseSRWLockShared(&m.mx)
}
pub fn (mut m RwMutex) w_unlock() {
pub fn (mut m RwMutex) unlock() {
C.ReleaseSRWLockExclusive(&m.mx)
}

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.m_lock()
wg.task_count_mutex.@lock()
defer {
wg.task_count_mutex.unlock()
}

View File

@ -2756,7 +2756,7 @@ fn (mut g Gen) expr(node ast.Expr) {
}
ast.PostfixExpr {
if node.auto_locked != '' {
g.writeln('sync__RwMutex_w_lock(&$node.auto_locked->mtx);')
g.writeln('sync__RwMutex_lock(&$node.auto_locked->mtx);')
}
g.inside_map_postfix = true
g.expr(node.expr)
@ -2764,7 +2764,7 @@ fn (mut g Gen) expr(node ast.Expr) {
g.write(node.op.str())
if node.auto_locked != '' {
g.writeln(';')
g.write('sync__RwMutex_w_unlock(&$node.auto_locked->mtx)')
g.write('sync__RwMutex_unlock(&$node.auto_locked->mtx)')
}
}
ast.PrefixExpr {
@ -3019,7 +3019,7 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
// string + string, string == string etc
// g.infix_op = node.op
if node.auto_locked != '' {
g.writeln('sync__RwMutex_w_lock(&$node.auto_locked->mtx);')
g.writeln('sync__RwMutex_lock(&$node.auto_locked->mtx);')
}
left_type := g.unwrap_generic(node.left_type)
left_sym := g.table.get_type_symbol(left_type)
@ -3409,18 +3409,18 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
}
if node.auto_locked != '' {
g.writeln(';')
g.write('sync__RwMutex_w_unlock(&$node.auto_locked->mtx)')
g.write('sync__RwMutex_unlock(&$node.auto_locked->mtx)')
}
}
fn (mut g Gen) lock_expr(node ast.LockExpr) {
mut lock_prefixes := []byte{len: 0, cap: node.lockeds.len}
mut lock_prefixes := []string{len: 0, cap: node.lockeds.len}
for id in node.lockeds {
name := id.name
deref := if id.is_mut { '->' } else { '.' }
lock_prefix := if node.is_rlock { `r` } else { `w` }
lock_prefix := if node.is_rlock { 'r' } else { '' }
lock_prefixes << lock_prefix // keep for unlock
g.writeln('sync__RwMutex_${lock_prefix:c}_lock(&$name${deref}mtx);')
g.writeln('sync__RwMutex_${lock_prefix}lock(&$name${deref}mtx);')
}
g.stmts(node.stmts)
// unlock in reverse order
@ -3429,7 +3429,7 @@ fn (mut g Gen) lock_expr(node ast.LockExpr) {
lock_prefix := lock_prefixes[i]
name := id.name
deref := if id.is_mut { '->' } else { '.' }
g.writeln('sync__RwMutex_${lock_prefix:c}_unlock(&$name${deref}mtx);')
g.writeln('sync__RwMutex_${lock_prefix}unlock(&$name${deref}mtx);')
}
}