mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Add a way to pass in a preconstructed value to ManagedStatic (#2175)
A lot of our cases don't need the lazy construction, but do need manual destruction.
This commit is contained in:
committed by
Peter Johnson
parent
5e08bb28f8
commit
9cb69c5b46
@@ -43,6 +43,7 @@ protected:
|
||||
mutable const ManagedStaticBase *Next;
|
||||
|
||||
void RegisterManagedStatic(void *(*creator)(), void (*deleter)(void*)) const;
|
||||
void RegisterManagedStatic(void *created, void (*deleter)(void*)) const;
|
||||
|
||||
public:
|
||||
/// isConstructed - Return true if this object has not been created yet.
|
||||
@@ -60,6 +61,12 @@ template <class C, class Creator = object_creator<C>,
|
||||
class Deleter = object_deleter<C>>
|
||||
class ManagedStatic : public ManagedStaticBase {
|
||||
public:
|
||||
ManagedStatic() = default;
|
||||
|
||||
ManagedStatic(C* created, void(*deleter)(void*)) {
|
||||
RegisterManagedStatic(created, deleter);
|
||||
}
|
||||
|
||||
// Accessors.
|
||||
C &operator*() {
|
||||
void *Tmp = Ptr.load(std::memory_order_acquire);
|
||||
|
||||
Reference in New Issue
Block a user