Jint: [Question] Is the engine meant to be used as a singleton?

Created on 21 Oct 2020  路  3Comments  路  Source: sebastienros/jint

I'm wondering if it's okay to just create instances of the engine as and when I need it or is it meant to be use as a singleton in the application?

All 3 comments

Engine is not thread safe so you shouldn't have it as a singleton in multi-threaded application. It's OK to create multiple instances.

To add to that, while the engine isn't thread safe, is is fine (and expected) that you'll reuse the engine to execute scripts multiple times.
This allows you to save on the initialization costs, especially if you want to have some init scripts / environment to offer.

You might also want to keep an eye on https://github.com/sebastienros/jint/pull/789 as there's probably going to be a default implementation for engine pool.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

appel1 picture appel1  路  25Comments

lahma picture lahma  路  15Comments

asdfgasdfsafgsdfa picture asdfgasdfsafgsdfa  路  17Comments

arivera12 picture arivera12  路  35Comments

Jugolo picture Jugolo  路  13Comments