#[repr(C)]pub struct PrSDKOpaqueEffectDataSuite {
pub AcquireOpaqueEffectData: Option<unsafe extern "C" fn(instanceID: csSDK_int32, outOpaqueEffectDataPP: *mut *mut OpaqueEffectDataType) -> PF_Err>,
pub RegisterOpaqueEffectData: Option<unsafe extern "C" fn(instanceID: csSDK_int32, ioOpaqueEffectDataPP: *mut *mut OpaqueEffectDataType) -> PF_Err>,
pub ReleaseOpaqueEffectData: Option<unsafe extern "C" fn(instanceID: csSDK_int32, outDisposeOpaqueEffectDataPP: *mut *mut OpaqueEffectDataType) -> PF_Err>,
}Expand description
This suite provides effects a means to share unflattened sequence data between its instances. The data is opaque to the host and effects are responsible for maintaining thread safety of the shared data. The host provides ref counting that the effect can use to manage the lifetime of the shared data.
Fields§
§AcquireOpaqueEffectData: Option<unsafe extern "C" fn(instanceID: csSDK_int32, outOpaqueEffectDataPP: *mut *mut OpaqueEffectDataType) -> PF_Err>Acquire pointer to opaque effect data. This is reference counted meaning that AcquireOpaqueEffectData and ReleaseOpaqueEffectData should always be called in pairs. If no opaque effect was registered for the given effect_ref AcquireOpaqueEffectData will return 0 and the reference count remains 0.
RegisterOpaqueEffectData: Option<unsafe extern "C" fn(instanceID: csSDK_int32, ioOpaqueEffectDataPP: *mut *mut OpaqueEffectDataType) -> PF_Err>Register opaque effect data. If multiple threads invoke RegisterOpaqueEffectData only one will be successful. The ioOpaqueEffectDataPP of the successful thread will be returned to all callers. Calling threads are always responsible for managing the data they register. This is the case whether or not threads are successful registering their data. Similarly, RegisterOpaqueEffectData always increments the internal reference count.
// // Sample code showing how to use RegisterOpaqueEffectData. // Note: code is simplified (not exception-safe, etc.) //
// // Try to acquire first, in case another thread registered the opaque effect data earlier // OpaqueEffectDataType * pData = 0; PF_Err err = opaqueEffectDataSuite->AcquireOpaqueEffectData(instanceID, &pData); assert(err == PF_Err_NONE);
// // If acquire did not return a valid pointer, create a new object and register it // otherwise we are done // if (pData == 0) { OpaqueEffectDataType * pNewData(new OpaqueEffectDataType()); pData = pNewData; err = opaqueEffectDataSuite->RegisterOpaqueEffectData(instanceID, &pData); assert(err == PF_Err_NONE);
// now we check if this thread actually succeeded registering // if the returned pData is unchanged it means that it was successful if (pData != pNewData) { delete pNewData; } }
// pData now points to the right OpaqueEffectDataType object and we can start using it …
ReleaseOpaqueEffectData: Option<unsafe extern "C" fn(instanceID: csSDK_int32, outDisposeOpaqueEffectDataPP: *mut *mut OpaqueEffectDataType) -> PF_Err>Release opaque effect data. This decrements the internal reference count. If the internal reference count goes to 0 outDisposeOpaqueEffectDataPP is set to the managed data that should be deleted, otherwise it is set to NULL. If the internal reference count goes to 0 any calls made to AcquireOpaqueEffectData will return 0 until new opaque effect data is registered via RegisterOpaqueEffectData.
Trait Implementations§
Source§impl Clone for PrSDKOpaqueEffectDataSuite
impl Clone for PrSDKOpaqueEffectDataSuite
Source§fn clone(&self) -> PrSDKOpaqueEffectDataSuite
fn clone(&self) -> PrSDKOpaqueEffectDataSuite
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more