Struct singleton::PreemptiveSingleton [] [src]

pub struct PreemptiveSingleton<T: Send> { /* fields omitted */ }

A pointer type for holding non-shared global state in multi-thread environment. Only the thread that sucessfully put data in it can access the data.

Methods

impl<T: Send> PreemptiveSingleton<T>
[src]

[src]

Create an uninitialized singleton.

[src]

Access the singleton; initialize it with Default::default() if it is uninitialized. Panic if it is taken previously by another thread.

[src]

Access the singleton; or return None if it is not yet uninitialized or taken previously by another thread.

[src]

Access the singleton; initialize it with custom function if it is uninitialized. Panic if it is taken previously by another thread.

[src]

Put the singleton into a finalized state, destruct the singleton value if it is initialized.

This is unsafe and only useful when the value holds other resources.

Trait Implementations

impl<T: Send> Drop for PreemptiveSingleton<T>
[src]

[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<T> Send for PreemptiveSingleton<T>

impl<T> Sync for PreemptiveSingleton<T>