Sometimes the value of a class member needs to be shared across all class instances. To make it easy to support this usecase, a new modifier will be introduced that lets members be singletons.
Example:
class MyType {
singleton_member: int32, singleton
}
The singleton member will be an extension of observable. This will cause the member to point to an object of the member type (an object of type int32 in the example). That way, the singleton can be locked/updated by using regular corto functions:
Initialize the singleton:
corto_update_begin(this->singleton_member);
if (!*this->singleton_member) { *this->singleton_member = 10; }
corto_update_end(this->singleton_member);
A class can use the object refcount to check if it needs to be deinitialized:
corto_update_begin(this->singleton_member);
if (corto_countof(this->singleton_member) {
// deinitialize code
}
corto_update_end(this->singleton_member);
Sometimes the value of a class member needs to be shared across all class instances. To make it easy to support this usecase, a new modifier will be introduced that lets members be singletons.
Example:
The singleton member will be an extension of observable. This will cause the member to point to an object of the member type (an object of type
int32
in the example). That way, the singleton can be locked/updated by using regular corto functions:Initialize the singleton:
A class can use the object refcount to check if it needs to be deinitialized: