pub struct CoolPropLib(/* private fields */);Expand description
Process-wide synchronization boundary for the loaded CoolProp dynamic library.
Use CoolPropLib::shared_access only for native operations known to support concurrent
execution. Use CoolPropLib::exclusive_access for configuration and debug changes, global
error or warning handling, REFPROP operations, VTPR construction or reload, tabular
backends, and operations whose concurrency guarantees are unknown. When in doubt, use
exclusive access.
Do not acquire a second access guard while another guard is held by the same thread. Drop the current guard before changing access modes.
For this synchronization boundary to be effective, all access to the bundled native library in
a process must go through COOLPROP. Constructing bindings::CoolProp directly bypasses
this boundary and requires equivalent process-wide synchronization from the caller.
Implementations§
Source§impl CoolPropLib
impl CoolPropLib
Acquires shared access to the native library.
A shared guard does not make an arbitrary native function or backend reentrant. Use it only
for operations explicitly known to support concurrent execution, such as calculations on
independent states backed by HEOS, INCOMP, IF97, SRK, PR, PCSAFT, or an
already-constructed VTPR state.
Some native functions report failure through a sentinel value and store details in the
process-global errstring. Do not release shared access and then treat that string as the
error from the failed call: another failure may replace it first. To retrieve attributable
error details:
- Release the shared guard.
- Acquire exclusive access.
- Read and discard any stale
errstringwithget_global_param_string, which clears the stored message. - Repeat the complete native call.
- Read
errstringwithget_global_param_stringbefore releasing the same exclusive guard.
If error details are not needed, perform only steps 1–3; no retry is required.
Lock poisoning is recovered transparently; access does not panic solely because a previous guard holder panicked.
§Examples
use coolprop_sys::COOLPROP;
let coolprop = COOLPROP.shared_access();
let critical_temperature = unsafe { coolprop.Props1SI(c"Water".as_ptr(), c"Tcrit".as_ptr()) };
assert!(critical_temperature.is_finite());Sourcepub fn exclusive_access(&self) -> ExclusiveAccess<'_>
pub fn exclusive_access(&self) -> ExclusiveAccess<'_>
Acquires exclusive access to the native library.
Use this for configuration changes, pending-error retrieval, REFPROP calls, VTPR state
construction, tabular backends, and other calls that touch mutable process-global state.
When a native call may set a process-global error or warning, keep the same exclusive guard
from that call through retrieval of its errstring or warnstring.
Lock poisoning is recovered transparently; access does not panic solely because a previous guard holder panicked.
§Examples
use coolprop_sys::COOLPROP;
let coolprop = COOLPROP.exclusive_access();
unsafe {
coolprop.set_debug_level(0);
}