From many places in my system I'm accessing constructor objects and functions that cloud benefit from being cached so i dont have to get from either globals or create new objects every time.
My original plan was to create something like this, and populate when i initialize the runtime, and clear before i drop the runtime.
struct ObjectCache {
array_ctor: Constructor<'static>,
// more stuff here
}
static OBJECT_CACHE: Lazy<RwLock<Option<ObjectCache>>> = Lazy::new(|| RwLock::new(None));
However this is not possible because:
NonNull<JSContext> cannot be shared between threads safely
within Option<ObjectCache>, the trait Sync is not implemented for NonNull<JSContext>
From many places in my system I'm accessing constructor objects and functions that cloud benefit from being cached so i dont have to get from either globals or create new objects every time.
My original plan was to create something like this, and populate when i initialize the runtime, and clear before i drop the runtime.
However this is not possible because:
Any other suggestion?