drexlerd / Loki

GNU General Public License v3.0
4 stars 3 forks source link

Moving towards zero cost abstraction #4

Closed drexlerd closed 10 months ago

drexlerd commented 10 months ago

The current PDDL data structure is very powerful and convenient. However, we want to provide a better abstraction that is closer to zero cost. The main issue is the usage of std::shared_ptr in the PDDL data structure which is not zero cost when copying: requires a redundant atomic increment and requires std::mutex locks to ensure that the ref count is synchronized a cross several threads.

One way to address this limitation is to translate the shared_ptr based data structure (shared_PDDL) to an analogous data structure based on a combination of std::unique_ptr and raw pointers. Since PDDL objects are const, this solves the thread synchronization problem.

Another step towards zero cost abstraction, would be to provide a non fragmented indexing scheme for each PDDL type. This can be easily addressed by splitting the PDDL factory into one for each type. To ensure non fragmented indices after user define compilation, we can provide a function to reparse the result of the compilation. To make the usage of indices safer, we could use a handle-like type for each PDDL type.

drexlerd commented 10 months ago

Removed shared ownership of PDDL objects entirely and moved to single ownership. Added non-fragmented indexing.