pub unsafe extern "C" fn setm(lock: I) -> I
Expand description
Set whether interning symbols uses a lock: lock
is either 0 or 1.
Returns the previously set value.
§Example
#[macro_use]
extern crate kdbplus;
use kdbplus::api::*;
use kdbplus::api::native::*;
#[no_mangle]
pub extern "C" fn parallel_sym_change(list: K) -> K{
unsafe{
// `K` cannot have `Send` because it is a pointer but `k0` does.
let mut inner=*list;
// Lock symbol before creating an internal symbol on another thread.
setm(1);
let task=std::thread::spawn(move || {
inner.as_mut_slice::<S>()[0]=ss(str_to_S!("replaced"));
inner
});
list.as_mut_slice::<S>()[1]=ss(str_to_S!("symbolbol"));
match task.join(){
Err(_) => {
// Unlock.
setm(0);
krr(null_terminated_str_to_const_S("oh no"))
},
Ok(l) => {
// Unlock.
setm(0);
(*list)=l;
// Increment reference count for copy.
r1(list)
}
}
}
}
q)alms_with_left_hand: `libc_api_examples 2: (`parallel_sym_change; 2);
q)alms_with_left_hand[`a`b];
`replaced`symbolbol