Struct videocore_gencmd::global::GlobalInstance [−][src]
pub struct GlobalInstance { /* fields omitted */ }
Implementations
Returns a singleton instance.
If the instance already exists, the same instance is returned.
Otherwise a new instance is created using Self::new
.
Memory race
There is a race between the last strong reference being decremented and dropped and the GlobalInstance
inside of it being deinitialized.
This means that for a little while this function may return GencmdInitError::AlreadyInitialized
even
when the global singleton is no longer being held.
GlobalInstnace Drop starts
| Error here as an instance still exists
| | GlobalInstnace Drop ends
v v v
ONE_INSTANCE: |------------|_________|
Weak Arc : |-------|_________|....
Strong Arc : |-------| |....
^ ^
| Attempt to create new singleton instance
Drop Arc here, weak becomes non-upgradable
To alleviate this, this function may spin around that error until the GlobalInstnace::drop
finishes. However, if the second instance
is being held by an external actor and not through the global singleton functionality, then the spin will never finish unless it is
limited. For that purpose, this function takes the SPIN_RETRY_LIMIT
generic argument which can be used to limit the maximum number of
retry spins before an error is returned (that is, new
will be attempted SPIN_RETRY_LIMIT + 1
times).
Initializes a new instance of videocore connection.
Returns an error if another connection already exists.
It is up to the caller to share that one connection to all
places where they might need it. However, if “global_singleton”
feature is enabled, a global, lazy singleton implementation is
provided in singleton
module.
Retrieves the response from the instance.
Returns number of bytes read into buffer
(excluding the null terminator).
Panic
Will panic if this instance has been deinitialized.
Returns true if self.deinit
has been called at least once on this instance.
Deinitializes self
, returning a potential error.
If deinit
is not called,deinit_ref_mut
will be called in drop
and will panic on error.
Deinitializes self
, returning a potential error.
It’s okay to call this multiple times, but after a deinitialization other methods that work with this instance will panic.
If deinit_ref_mut
is not called it will be called in drop
and will panic on error.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for GlobalInstance
impl !Sync for GlobalInstance
impl Unpin for GlobalInstance
impl UnwindSafe for GlobalInstance