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

all: experimental locked concurrency support, part 1 (#5637)

This commit is contained in:
Uwe Krüger
2020-07-04 12:44:25 +02:00
committed by GitHub
parent 27149ba8bc
commit 3b067f5f85
27 changed files with 510 additions and 51 deletions

View File

@ -181,7 +181,7 @@ fn (mut cb Clipboard) free() {
}
fn (mut cb Clipboard) clear(){
cb.mutex.lock()
cb.mutex.m_lock()
C.XSetSelectionOwner(cb.display, cb.selection, C.Window(C.None), C.CurrentTime)
C.XFlush(cb.display)
cb.is_owner = false
@ -200,7 +200,7 @@ fn (cb &Clipboard) take_ownership(){
fn (mut cb Clipboard) set_text(text string) bool {
if cb.window == C.Window(C.None) {return false}
cb.mutex.lock()
cb.mutex.m_lock()
cb.text = text
cb.is_owner = true
cb.take_ownership()
@ -238,7 +238,7 @@ fn (mut cb Clipboard) transmit_selection(xse &C.XSelectionEvent) bool {
targets := cb.get_supported_targets()
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.lock()
cb.mutex.m_lock()
C.XChangeProperty(xse.display, xse.requestor, xse.property, xse.target, 8, C.PropModeReplace, cb.text.str, cb.text.len)
cb.mutex.unlock()
} else {
@ -265,7 +265,7 @@ fn (mut cb Clipboard) start_listener(){
}
C.SelectionClear {
if event.xselectionclear.window == cb.window && event.xselectionclear.selection == cb.selection {
cb.mutex.lock()
cb.mutex.m_lock()
cb.is_owner = false
cb.text = ""
cb.mutex.unlock()
@ -304,7 +304,7 @@ fn (mut cb Clipboard) start_listener(){
} else if event.xselection.target == to_be_requested {
sent_request = false
to_be_requested = C.Atom(0)
cb.mutex.lock()
cb.mutex.m_lock()
prop := read_property(event.xselection.display, event.xselection.requestor, event.xselection.property)
C.XDeleteProperty(event.xselection.display, event.xselection.requestor, event.xselection.property)
if cb.is_supported_target(prop.actual_type) {