cortoproject / corto

A hierarchical object store for connecting realtime machine data with web applications, historians & more
https://www.corto.io
MIT License
87 stars 14 forks source link

Simplify object state #613

Closed SanderMertens closed 7 years ago

SanderMertens commented 7 years ago

Currently, objects have a state mask that tracks where they are in their lifecycle. This mask includes the following constants: DECLARED, VALID, DEFINED, DESTRUCTED.

The DECLARED mask is assigned to all declared objects (all objects except orphaned objects). The VALID mask is assigned to all objects for which the initializer was success and that are not invalid. The DEFINED state is assigned to all objects that have been defined. DESTRUCTED is assigned to objects that have been deleted (but not yet deallocated).

The semantics of the VALID state are not straightforward. It is a mix between successful init and validity of the object value. In practice, a user would have to check for both DEFINED and VALID to determine whether the object value can be interpreted.

These two states can be merged into one state, that simply indicates whether object value is valid or not. The value of an object is not valid right after declaration, but will become valid after the object is defined. If a construct or validate fails, or the invalidate function is called, the VALID flag will be removed.

SanderMertens commented 7 years ago

The DECLARED state is currently only used to indicate whether an object is orphaned or not (other objects are always declared).

Therefore, DECLARED state can be removed, and replaced with a orphaned bit in the object header.