Execution Context
Thread-safe execution context for model caching.
-
class nabla.core.execution_context.ThreadSafeExecutionContext[source]
Bases: object
Thread-safe wrapper around the global execution context dictionary.
-
__init__()[source]
-
get(key)[source]
Get a model from the cache. Returns None if not found.
-
set(key, model)[source]
Set a model in the cache.
-
get_or_create(key, factory)[source]
Get a model from cache, or create it using the factory function if not found.
This is thread-safe and ensures only one thread creates the model for a given key.
-
contains(key)[source]
Check if a key exists in the cache.
-
clear()[source]
Clear the entire cache. Useful for testing or memory management.
-
size()[source]
Get the current size of the cache.