Skip to content

[isolated-workers] Have ability to call dispose on classes when destroyed for v1? #53

Open
@bfgeek

Description

@bfgeek

E.g.

[NoInterfaceObject]
interface Disposable {
  void dispose(); 
};

Spec wording:
Creating classes registered on the global scope is the responsibility user agent. To allow authors to release resources used by these classes, the user agent must call the dispose() method on the class before destroying.

The only use-case for this is shared cache-objects on the global scope, and allowing code to clean up after themselves. Is it worth putting this in v1?

E.g.

var sharedCache = null;
var sharedCacheCount = 0;
registerAClass('foo', class Foo {
  constructor() {
    sharedCacheCount++;
    if (!sharedCache) buildExpensiveCache();
  },
  dispose() {
    sharedCacheCount--;
    if (!sharedCacheCount) sharedCache = null; // Frees memory.
  }
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions