Use AtomicPtr instead of Mutex
parent
49f67ffc61
commit
13d8d1cf1d
|
@ -1,11 +1,12 @@
|
|||
/* generated by rust_qt_binding_generator */
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
||||
#![allow(needless_pass_by_value)]
|
||||
use libc::{c_char, c_ushort, c_int};
|
||||
use std::slice;
|
||||
use std::char::decode_utf16;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
use std::ptr::null;
|
||||
|
||||
use implementation::*;
|
||||
|
@ -97,14 +98,15 @@ pub struct DemoQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct DemoEmitter {
|
||||
qobject: Arc<Mutex<*const DemoQObject>>,
|
||||
qobject: Arc<AtomicPtr<DemoQObject>>,
|
||||
}
|
||||
|
||||
unsafe impl Send for DemoEmitter {}
|
||||
|
||||
impl DemoEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const DemoQObject = null();
|
||||
self.qobject.store(n as *mut DemoQObject, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,13 +192,13 @@ pub extern "C" fn demo_new(
|
|||
time_series_end_remove_rows: fn(*const TimeSeriesQObject),
|
||||
) -> *mut Demo {
|
||||
let fibonacci_emit = FibonacciEmitter {
|
||||
qobject: Arc::new(Mutex::new(fibonacci)),
|
||||
qobject: Arc::new(AtomicPtr::new(fibonacci)),
|
||||
input_changed: fibonacci_input_changed,
|
||||
result_changed: fibonacci_result_changed,
|
||||
};
|
||||
let d_fibonacci = Fibonacci::new(fibonacci_emit);
|
||||
let fibonacci_list_emit = FibonacciListEmitter {
|
||||
qobject: Arc::new(Mutex::new(fibonacci_list)),
|
||||
qobject: Arc::new(AtomicPtr::new(fibonacci_list)),
|
||||
new_data_ready: fibonacci_list_new_data_ready,
|
||||
};
|
||||
let model = FibonacciListList {
|
||||
|
@ -215,7 +217,7 @@ pub extern "C" fn demo_new(
|
|||
};
|
||||
let d_fibonacci_list = FibonacciList::new(fibonacci_list_emit, model);
|
||||
let file_system_tree_emit = FileSystemTreeEmitter {
|
||||
qobject: Arc::new(Mutex::new(file_system_tree)),
|
||||
qobject: Arc::new(AtomicPtr::new(file_system_tree)),
|
||||
path_changed: file_system_tree_path_changed,
|
||||
new_data_ready: file_system_tree_new_data_ready,
|
||||
};
|
||||
|
@ -235,7 +237,7 @@ pub extern "C" fn demo_new(
|
|||
};
|
||||
let d_file_system_tree = FileSystemTree::new(file_system_tree_emit, model);
|
||||
let processes_emit = ProcessesEmitter {
|
||||
qobject: Arc::new(Mutex::new(processes)),
|
||||
qobject: Arc::new(AtomicPtr::new(processes)),
|
||||
active_changed: processes_active_changed,
|
||||
new_data_ready: processes_new_data_ready,
|
||||
};
|
||||
|
@ -255,7 +257,7 @@ pub extern "C" fn demo_new(
|
|||
};
|
||||
let d_processes = Processes::new(processes_emit, model);
|
||||
let time_series_emit = TimeSeriesEmitter {
|
||||
qobject: Arc::new(Mutex::new(time_series)),
|
||||
qobject: Arc::new(AtomicPtr::new(time_series)),
|
||||
new_data_ready: time_series_new_data_ready,
|
||||
};
|
||||
let model = TimeSeriesList {
|
||||
|
@ -274,7 +276,7 @@ pub extern "C" fn demo_new(
|
|||
};
|
||||
let d_time_series = TimeSeries::new(time_series_emit, model);
|
||||
let demo_emit = DemoEmitter {
|
||||
qobject: Arc::new(Mutex::new(demo)),
|
||||
qobject: Arc::new(AtomicPtr::new(demo)),
|
||||
};
|
||||
let d_demo = Demo::new(demo_emit,
|
||||
d_fibonacci,
|
||||
|
@ -319,7 +321,7 @@ pub struct FibonacciQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct FibonacciEmitter {
|
||||
qobject: Arc<Mutex<*const FibonacciQObject>>,
|
||||
qobject: Arc<AtomicPtr<FibonacciQObject>>,
|
||||
input_changed: fn(*const FibonacciQObject),
|
||||
result_changed: fn(*const FibonacciQObject),
|
||||
}
|
||||
|
@ -328,16 +330,17 @@ unsafe impl Send for FibonacciEmitter {}
|
|||
|
||||
impl FibonacciEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const FibonacciQObject = null();
|
||||
self.qobject.store(n as *mut FibonacciQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn input_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.input_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn result_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.result_changed)(ptr);
|
||||
}
|
||||
|
@ -359,7 +362,7 @@ pub extern "C" fn fibonacci_new(
|
|||
fibonacci_result_changed: fn(*const FibonacciQObject),
|
||||
) -> *mut Fibonacci {
|
||||
let fibonacci_emit = FibonacciEmitter {
|
||||
qobject: Arc::new(Mutex::new(fibonacci)),
|
||||
qobject: Arc::new(AtomicPtr::new(fibonacci)),
|
||||
input_changed: fibonacci_input_changed,
|
||||
result_changed: fibonacci_result_changed,
|
||||
};
|
||||
|
@ -391,7 +394,7 @@ pub struct FibonacciListQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct FibonacciListEmitter {
|
||||
qobject: Arc<Mutex<*const FibonacciListQObject>>,
|
||||
qobject: Arc<AtomicPtr<FibonacciListQObject>>,
|
||||
new_data_ready: fn(*const FibonacciListQObject),
|
||||
}
|
||||
|
||||
|
@ -399,10 +402,11 @@ unsafe impl Send for FibonacciListEmitter {}
|
|||
|
||||
impl FibonacciListEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const FibonacciListQObject = null();
|
||||
self.qobject.store(n as *mut FibonacciListQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn new_data_ready(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.new_data_ready)(ptr);
|
||||
}
|
||||
|
@ -493,7 +497,7 @@ pub extern "C" fn fibonacci_list_new(
|
|||
fibonacci_list_end_remove_rows: fn(*const FibonacciListQObject),
|
||||
) -> *mut FibonacciList {
|
||||
let fibonacci_list_emit = FibonacciListEmitter {
|
||||
qobject: Arc::new(Mutex::new(fibonacci_list)),
|
||||
qobject: Arc::new(AtomicPtr::new(fibonacci_list)),
|
||||
new_data_ready: fibonacci_list_new_data_ready,
|
||||
};
|
||||
let model = FibonacciListList {
|
||||
|
@ -564,7 +568,7 @@ pub struct FileSystemTreeQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct FileSystemTreeEmitter {
|
||||
qobject: Arc<Mutex<*const FileSystemTreeQObject>>,
|
||||
qobject: Arc<AtomicPtr<FileSystemTreeQObject>>,
|
||||
path_changed: fn(*const FileSystemTreeQObject),
|
||||
new_data_ready: fn(*const FileSystemTreeQObject, index: COption<usize>),
|
||||
}
|
||||
|
@ -573,16 +577,17 @@ unsafe impl Send for FileSystemTreeEmitter {}
|
|||
|
||||
impl FileSystemTreeEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const FileSystemTreeQObject = null();
|
||||
self.qobject.store(n as *mut FileSystemTreeQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn path_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.path_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn new_data_ready(&self, item: Option<usize>) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.new_data_ready)(ptr, item.into());
|
||||
}
|
||||
|
@ -682,7 +687,7 @@ pub extern "C" fn file_system_tree_new(
|
|||
file_system_tree_end_remove_rows: fn(*const FileSystemTreeQObject),
|
||||
) -> *mut FileSystemTree {
|
||||
let file_system_tree_emit = FileSystemTreeEmitter {
|
||||
qobject: Arc::new(Mutex::new(file_system_tree)),
|
||||
qobject: Arc::new(AtomicPtr::new(file_system_tree)),
|
||||
path_changed: file_system_tree_path_changed,
|
||||
new_data_ready: file_system_tree_new_data_ready,
|
||||
};
|
||||
|
@ -858,7 +863,7 @@ pub struct ProcessesQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct ProcessesEmitter {
|
||||
qobject: Arc<Mutex<*const ProcessesQObject>>,
|
||||
qobject: Arc<AtomicPtr<ProcessesQObject>>,
|
||||
active_changed: fn(*const ProcessesQObject),
|
||||
new_data_ready: fn(*const ProcessesQObject, index: COption<usize>),
|
||||
}
|
||||
|
@ -867,16 +872,17 @@ unsafe impl Send for ProcessesEmitter {}
|
|||
|
||||
impl ProcessesEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const ProcessesQObject = null();
|
||||
self.qobject.store(n as *mut ProcessesQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn active_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.active_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn new_data_ready(&self, item: Option<usize>) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.new_data_ready)(ptr, item.into());
|
||||
}
|
||||
|
@ -977,7 +983,7 @@ pub extern "C" fn processes_new(
|
|||
processes_end_remove_rows: fn(*const ProcessesQObject),
|
||||
) -> *mut Processes {
|
||||
let processes_emit = ProcessesEmitter {
|
||||
qobject: Arc::new(Mutex::new(processes)),
|
||||
qobject: Arc::new(AtomicPtr::new(processes)),
|
||||
active_changed: processes_active_changed,
|
||||
new_data_ready: processes_new_data_ready,
|
||||
};
|
||||
|
@ -1133,7 +1139,7 @@ pub struct TimeSeriesQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct TimeSeriesEmitter {
|
||||
qobject: Arc<Mutex<*const TimeSeriesQObject>>,
|
||||
qobject: Arc<AtomicPtr<TimeSeriesQObject>>,
|
||||
new_data_ready: fn(*const TimeSeriesQObject),
|
||||
}
|
||||
|
||||
|
@ -1141,10 +1147,11 @@ unsafe impl Send for TimeSeriesEmitter {}
|
|||
|
||||
impl TimeSeriesEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const TimeSeriesQObject = null();
|
||||
self.qobject.store(n as *mut TimeSeriesQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn new_data_ready(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.new_data_ready)(ptr);
|
||||
}
|
||||
|
@ -1239,7 +1246,7 @@ pub extern "C" fn time_series_new(
|
|||
time_series_end_remove_rows: fn(*const TimeSeriesQObject),
|
||||
) -> *mut TimeSeries {
|
||||
let time_series_emit = TimeSeriesEmitter {
|
||||
qobject: Arc::new(Mutex::new(time_series)),
|
||||
qobject: Arc::new(AtomicPtr::new(time_series)),
|
||||
new_data_ready: time_series_new_data_ready,
|
||||
};
|
||||
let model = TimeSeriesList {
|
||||
|
|
18
src/rust.rs
18
src/rust.rs
|
@ -139,7 +139,7 @@ fn r_constructor_args(r: &mut Vec<u8>, name: &str, o: &Object, conf: &Config) ->
|
|||
writeln!(
|
||||
r,
|
||||
" let {}_emit = {}Emitter {{
|
||||
qobject: Arc::new(Mutex::new({0})),",
|
||||
qobject: Arc::new(AtomicPtr::new({0})),",
|
||||
snake_case(name),
|
||||
o.name
|
||||
)?;
|
||||
|
@ -296,7 +296,7 @@ pub struct {}QObject {{}}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct {0}Emitter {{
|
||||
qobject: Arc<Mutex<*const {0}QObject>>,",
|
||||
qobject: Arc<AtomicPtr<{0}QObject>>,",
|
||||
o.name
|
||||
)?;
|
||||
for (name, p) in &o.properties {
|
||||
|
@ -327,7 +327,8 @@ unsafe impl Send for {}Emitter {{}}
|
|||
|
||||
impl {0}Emitter {{
|
||||
fn clear(&self) {{
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const {0}QObject = null();
|
||||
self.qobject.store(n as *mut {0}QObject, Ordering::SeqCst);
|
||||
}}",
|
||||
o.name
|
||||
)?;
|
||||
|
@ -339,7 +340,7 @@ impl {0}Emitter {{
|
|||
writeln!(
|
||||
r,
|
||||
" pub fn {}_changed(&self) {{
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {{
|
||||
(self.{0}_changed)(ptr);
|
||||
}}
|
||||
|
@ -352,7 +353,7 @@ impl {0}Emitter {{
|
|||
writeln!(
|
||||
r,
|
||||
" pub fn new_data_ready(&self) {{
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {{
|
||||
(self.new_data_ready)(ptr);
|
||||
}}
|
||||
|
@ -362,7 +363,7 @@ impl {0}Emitter {{
|
|||
writeln!(
|
||||
r,
|
||||
" pub fn new_data_ready(&self, item: Option<usize>) {{
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {{
|
||||
(self.new_data_ready)(ptr, item.into());
|
||||
}}
|
||||
|
@ -1229,12 +1230,13 @@ pub fn write_interface(conf: &Config) -> Result<()> {
|
|||
r,
|
||||
"/* generated by rust_qt_binding_generator */
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
||||
#![allow(needless_pass_by_value)]
|
||||
use libc::{{c_char, c_ushort, c_int}};
|
||||
use std::slice;
|
||||
use std::char::decode_utf16;
|
||||
|
||||
use std::sync::{{Arc, Mutex}};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{{AtomicPtr, Ordering}};
|
||||
use std::ptr::null;
|
||||
|
||||
use {}::*;",
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/* generated by rust_qt_binding_generator */
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
||||
#![allow(needless_pass_by_value)]
|
||||
use libc::{c_char, c_ushort, c_int};
|
||||
use std::slice;
|
||||
use std::char::decode_utf16;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
use std::ptr::null;
|
||||
|
||||
use implementation::*;
|
||||
|
@ -46,7 +47,7 @@ pub struct PersonQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct PersonEmitter {
|
||||
qobject: Arc<Mutex<*const PersonQObject>>,
|
||||
qobject: Arc<AtomicPtr<PersonQObject>>,
|
||||
user_name_changed: fn(*const PersonQObject),
|
||||
}
|
||||
|
||||
|
@ -54,10 +55,11 @@ unsafe impl Send for PersonEmitter {}
|
|||
|
||||
impl PersonEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const PersonQObject = null();
|
||||
self.qobject.store(n as *mut PersonQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn user_name_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.user_name_changed)(ptr);
|
||||
}
|
||||
|
@ -83,7 +85,7 @@ pub extern "C" fn person_new(
|
|||
person_user_name_changed: fn(*const PersonQObject),
|
||||
) -> *mut Person {
|
||||
let person_emit = PersonEmitter {
|
||||
qobject: Arc::new(Mutex::new(person)),
|
||||
qobject: Arc::new(AtomicPtr::new(person)),
|
||||
user_name_changed: person_user_name_changed,
|
||||
};
|
||||
let d_person = Person::new(person_emit);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/* generated by rust_qt_binding_generator */
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
||||
#![allow(needless_pass_by_value)]
|
||||
use libc::{c_char, c_ushort, c_int};
|
||||
use std::slice;
|
||||
use std::char::decode_utf16;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
use std::ptr::null;
|
||||
|
||||
use implementation::*;
|
||||
|
@ -94,7 +95,7 @@ pub struct NoRoleQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct NoRoleEmitter {
|
||||
qobject: Arc<Mutex<*const NoRoleQObject>>,
|
||||
qobject: Arc<AtomicPtr<NoRoleQObject>>,
|
||||
new_data_ready: fn(*const NoRoleQObject),
|
||||
}
|
||||
|
||||
|
@ -102,10 +103,11 @@ unsafe impl Send for NoRoleEmitter {}
|
|||
|
||||
impl NoRoleEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const NoRoleQObject = null();
|
||||
self.qobject.store(n as *mut NoRoleQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn new_data_ready(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.new_data_ready)(ptr);
|
||||
}
|
||||
|
@ -198,7 +200,7 @@ pub extern "C" fn no_role_new(
|
|||
no_role_end_remove_rows: fn(*const NoRoleQObject),
|
||||
) -> *mut NoRole {
|
||||
let no_role_emit = NoRoleEmitter {
|
||||
qobject: Arc::new(Mutex::new(no_role)),
|
||||
qobject: Arc::new(AtomicPtr::new(no_role)),
|
||||
new_data_ready: no_role_new_data_ready,
|
||||
};
|
||||
let model = NoRoleList {
|
||||
|
@ -294,7 +296,7 @@ pub struct PersonsQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct PersonsEmitter {
|
||||
qobject: Arc<Mutex<*const PersonsQObject>>,
|
||||
qobject: Arc<AtomicPtr<PersonsQObject>>,
|
||||
new_data_ready: fn(*const PersonsQObject),
|
||||
}
|
||||
|
||||
|
@ -302,10 +304,11 @@ unsafe impl Send for PersonsEmitter {}
|
|||
|
||||
impl PersonsEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const PersonsQObject = null();
|
||||
self.qobject.store(n as *mut PersonsQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn new_data_ready(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.new_data_ready)(ptr);
|
||||
}
|
||||
|
@ -396,7 +399,7 @@ pub extern "C" fn persons_new(
|
|||
persons_end_remove_rows: fn(*const PersonsQObject),
|
||||
) -> *mut Persons {
|
||||
let persons_emit = PersonsEmitter {
|
||||
qobject: Arc::new(Mutex::new(persons)),
|
||||
qobject: Arc::new(AtomicPtr::new(persons)),
|
||||
new_data_ready: persons_new_data_ready,
|
||||
};
|
||||
let model = PersonsList {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/* generated by rust_qt_binding_generator */
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
||||
#![allow(needless_pass_by_value)]
|
||||
use libc::{c_char, c_ushort, c_int};
|
||||
use std::slice;
|
||||
use std::char::decode_utf16;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
use std::ptr::null;
|
||||
|
||||
use implementation::*;
|
||||
|
@ -97,7 +98,7 @@ pub struct ListQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct ListEmitter {
|
||||
qobject: Arc<Mutex<*const ListQObject>>,
|
||||
qobject: Arc<AtomicPtr<ListQObject>>,
|
||||
new_data_ready: fn(*const ListQObject),
|
||||
}
|
||||
|
||||
|
@ -105,10 +106,11 @@ unsafe impl Send for ListEmitter {}
|
|||
|
||||
impl ListEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const ListQObject = null();
|
||||
self.qobject.store(n as *mut ListQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn new_data_ready(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.new_data_ready)(ptr);
|
||||
}
|
||||
|
@ -229,7 +231,7 @@ pub extern "C" fn list_new(
|
|||
list_end_remove_rows: fn(*const ListQObject),
|
||||
) -> *mut List {
|
||||
let list_emit = ListEmitter {
|
||||
qobject: Arc::new(Mutex::new(list)),
|
||||
qobject: Arc::new(AtomicPtr::new(list)),
|
||||
new_data_ready: list_new_data_ready,
|
||||
};
|
||||
let model = ListList {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/* generated by rust_qt_binding_generator */
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
||||
#![allow(needless_pass_by_value)]
|
||||
use libc::{c_char, c_ushort, c_int};
|
||||
use std::slice;
|
||||
use std::char::decode_utf16;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
use std::ptr::null;
|
||||
|
||||
use implementation::*;
|
||||
|
@ -43,7 +44,7 @@ pub struct PersonQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct PersonEmitter {
|
||||
qobject: Arc<Mutex<*const PersonQObject>>,
|
||||
qobject: Arc<AtomicPtr<PersonQObject>>,
|
||||
user_name_changed: fn(*const PersonQObject),
|
||||
}
|
||||
|
||||
|
@ -51,10 +52,11 @@ unsafe impl Send for PersonEmitter {}
|
|||
|
||||
impl PersonEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const PersonQObject = null();
|
||||
self.qobject.store(n as *mut PersonQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn user_name_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.user_name_changed)(ptr);
|
||||
}
|
||||
|
@ -74,7 +76,7 @@ pub extern "C" fn person_new(
|
|||
person_user_name_changed: fn(*const PersonQObject),
|
||||
) -> *mut Person {
|
||||
let person_emit = PersonEmitter {
|
||||
qobject: Arc::new(Mutex::new(person)),
|
||||
qobject: Arc::new(AtomicPtr::new(person)),
|
||||
user_name_changed: person_user_name_changed,
|
||||
};
|
||||
let d_person = Person::new(person_emit);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/* generated by rust_qt_binding_generator */
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
||||
#![allow(needless_pass_by_value)]
|
||||
use libc::{c_char, c_ushort, c_int};
|
||||
use std::slice;
|
||||
use std::char::decode_utf16;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
use std::ptr::null;
|
||||
|
||||
use implementation::*;
|
||||
|
@ -83,7 +84,7 @@ pub struct ObjectQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct ObjectEmitter {
|
||||
qobject: Arc<Mutex<*const ObjectQObject>>,
|
||||
qobject: Arc<AtomicPtr<ObjectQObject>>,
|
||||
boolean_changed: fn(*const ObjectQObject),
|
||||
bytearray_changed: fn(*const ObjectQObject),
|
||||
f32_changed: fn(*const ObjectQObject),
|
||||
|
@ -108,112 +109,113 @@ unsafe impl Send for ObjectEmitter {}
|
|||
|
||||
impl ObjectEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const ObjectQObject = null();
|
||||
self.qobject.store(n as *mut ObjectQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn boolean_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.boolean_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn bytearray_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.bytearray_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn f32_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.f32_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn f64_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.f64_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn i16_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.i16_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn i32_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.i32_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn i64_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.i64_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn i8_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.i8_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn optional_boolean_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.optional_boolean_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn optional_bytearray_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.optional_bytearray_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn optional_string_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.optional_string_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn optional_u64_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.optional_u64_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn string_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.string_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn string_by_function_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.string_by_function_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn u16_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.u16_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn u32_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.u32_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn u64_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.u64_changed)(ptr);
|
||||
}
|
||||
}
|
||||
pub fn u8_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.u8_changed)(ptr);
|
||||
}
|
||||
|
@ -283,7 +285,7 @@ pub extern "C" fn object_new(
|
|||
object_u8_changed: fn(*const ObjectQObject),
|
||||
) -> *mut Object {
|
||||
let object_emit = ObjectEmitter {
|
||||
qobject: Arc::new(Mutex::new(object)),
|
||||
qobject: Arc::new(AtomicPtr::new(object)),
|
||||
boolean_changed: object_boolean_changed,
|
||||
bytearray_changed: object_bytearray_changed,
|
||||
f32_changed: object_f32_changed,
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/* generated by rust_qt_binding_generator */
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
||||
#![allow(needless_pass_by_value)]
|
||||
use libc::{c_char, c_ushort, c_int};
|
||||
use std::slice;
|
||||
use std::char::decode_utf16;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
use std::ptr::null;
|
||||
|
||||
use implementation::*;
|
||||
|
@ -43,14 +44,15 @@ pub struct GroupQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct GroupEmitter {
|
||||
qobject: Arc<Mutex<*const GroupQObject>>,
|
||||
qobject: Arc<AtomicPtr<GroupQObject>>,
|
||||
}
|
||||
|
||||
unsafe impl Send for GroupEmitter {}
|
||||
|
||||
impl GroupEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const GroupQObject = null();
|
||||
self.qobject.store(n as *mut GroupQObject, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,17 +72,17 @@ pub extern "C" fn group_new(
|
|||
object_description_changed: fn(*const InnerObjectQObject),
|
||||
) -> *mut Group {
|
||||
let object_emit = InnerObjectEmitter {
|
||||
qobject: Arc::new(Mutex::new(object)),
|
||||
qobject: Arc::new(AtomicPtr::new(object)),
|
||||
description_changed: object_description_changed,
|
||||
};
|
||||
let d_object = InnerObject::new(object_emit);
|
||||
let person_emit = PersonEmitter {
|
||||
qobject: Arc::new(Mutex::new(person)),
|
||||
qobject: Arc::new(AtomicPtr::new(person)),
|
||||
};
|
||||
let d_person = Person::new(person_emit,
|
||||
d_object);
|
||||
let group_emit = GroupEmitter {
|
||||
qobject: Arc::new(Mutex::new(group)),
|
||||
qobject: Arc::new(AtomicPtr::new(group)),
|
||||
};
|
||||
let d_group = Group::new(group_emit,
|
||||
d_person);
|
||||
|
@ -101,7 +103,7 @@ pub struct InnerObjectQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct InnerObjectEmitter {
|
||||
qobject: Arc<Mutex<*const InnerObjectQObject>>,
|
||||
qobject: Arc<AtomicPtr<InnerObjectQObject>>,
|
||||
description_changed: fn(*const InnerObjectQObject),
|
||||
}
|
||||
|
||||
|
@ -109,10 +111,11 @@ unsafe impl Send for InnerObjectEmitter {}
|
|||
|
||||
impl InnerObjectEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const InnerObjectQObject = null();
|
||||
self.qobject.store(n as *mut InnerObjectQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn description_changed(&self) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.description_changed)(ptr);
|
||||
}
|
||||
|
@ -132,7 +135,7 @@ pub extern "C" fn inner_object_new(
|
|||
inner_object_description_changed: fn(*const InnerObjectQObject),
|
||||
) -> *mut InnerObject {
|
||||
let inner_object_emit = InnerObjectEmitter {
|
||||
qobject: Arc::new(Mutex::new(inner_object)),
|
||||
qobject: Arc::new(AtomicPtr::new(inner_object)),
|
||||
description_changed: inner_object_description_changed,
|
||||
};
|
||||
let d_inner_object = InnerObject::new(inner_object_emit);
|
||||
|
@ -168,14 +171,15 @@ pub struct PersonQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct PersonEmitter {
|
||||
qobject: Arc<Mutex<*const PersonQObject>>,
|
||||
qobject: Arc<AtomicPtr<PersonQObject>>,
|
||||
}
|
||||
|
||||
unsafe impl Send for PersonEmitter {}
|
||||
|
||||
impl PersonEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const PersonQObject = null();
|
||||
self.qobject.store(n as *mut PersonQObject, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,12 +198,12 @@ pub extern "C" fn person_new(
|
|||
object_description_changed: fn(*const InnerObjectQObject),
|
||||
) -> *mut Person {
|
||||
let object_emit = InnerObjectEmitter {
|
||||
qobject: Arc::new(Mutex::new(object)),
|
||||
qobject: Arc::new(AtomicPtr::new(object)),
|
||||
description_changed: object_description_changed,
|
||||
};
|
||||
let d_object = InnerObject::new(object_emit);
|
||||
let person_emit = PersonEmitter {
|
||||
qobject: Arc::new(Mutex::new(person)),
|
||||
qobject: Arc::new(AtomicPtr::new(person)),
|
||||
};
|
||||
let d_person = Person::new(person_emit,
|
||||
d_object);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/* generated by rust_qt_binding_generator */
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
||||
#![allow(needless_pass_by_value)]
|
||||
use libc::{c_char, c_ushort, c_int};
|
||||
use std::slice;
|
||||
use std::char::decode_utf16;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||
use std::ptr::null;
|
||||
|
||||
use implementation::*;
|
||||
|
@ -94,7 +95,7 @@ pub struct PersonsQObject {}
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct PersonsEmitter {
|
||||
qobject: Arc<Mutex<*const PersonsQObject>>,
|
||||
qobject: Arc<AtomicPtr<PersonsQObject>>,
|
||||
new_data_ready: fn(*const PersonsQObject, index: COption<usize>),
|
||||
}
|
||||
|
||||
|
@ -102,10 +103,11 @@ unsafe impl Send for PersonsEmitter {}
|
|||
|
||||
impl PersonsEmitter {
|
||||
fn clear(&self) {
|
||||
*self.qobject.lock().unwrap() = null();
|
||||
let n: *const PersonsQObject = null();
|
||||
self.qobject.store(n as *mut PersonsQObject, Ordering::SeqCst);
|
||||
}
|
||||
pub fn new_data_ready(&self, item: Option<usize>) {
|
||||
let ptr = *self.qobject.lock().unwrap();
|
||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||
if !ptr.is_null() {
|
||||
(self.new_data_ready)(ptr, item.into());
|
||||
}
|
||||
|
@ -198,7 +200,7 @@ pub extern "C" fn persons_new(
|
|||
persons_end_remove_rows: fn(*const PersonsQObject),
|
||||
) -> *mut Persons {
|
||||
let persons_emit = PersonsEmitter {
|
||||
qobject: Arc::new(Mutex::new(persons)),
|
||||
qobject: Arc::new(AtomicPtr::new(persons)),
|
||||
new_data_ready: persons_new_data_ready,
|
||||
};
|
||||
let model = PersonsTree {
|
||||
|
|
Loading…
Reference in New Issue