Optional_config: ConfigProtected_ctxProtected_lifecycleProtected_catchError handler for errors that are caught by the context. By default, errors are bubbled up to the parent context which is passed to the open method.
Protected_closeTo be overridden by subclasses.
Protected_openTo be overridden by subclasses.
await using resource = new Resource();
await resource.open();
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using
Closes the resource. If the resource is already closed, it does nothing.
Optionalctx: ContextCreates a new MessagePort connected to the worker runtime.
Opens the resource. If the resource is already open, it does nothing. If the resource is in an error state, it throws an error. If the resource is closed, it waits for it to close and then opens it.
Optionalctx: ContextContext to use for opening the resource. This context will receive errors that are not handled in _catch.
Calls the provided function, opening and closing the resource.
NOTE: Consider using using instead.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using
Waits until the resource is open.
In-thread worker for testing purposes. Creates a WorkerRuntime in the same thread using MessageChannel for communication.