Skip to content

Conversation

@medegor44
Copy link
Owner

Fix multithreading issue (only on windows)

@confirmit-horizons
Copy link

It doesn't look fixed.
You should explore how other competitors are solving the same issues. For example,

@medegor44 medegor44 force-pushed the ChakraCore_multithreading branch from f1a797f to 0947740 Compare October 12, 2021 08:48
var val = _engine.Evaluate(expression);
JsValue val;

lock (_engineSynchronizer)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to remove the lock and mention in the readme that jint is not thread safe. then it will be up to the user to sync

private readonly JsContext _context;

// stores registered delegates to prevent their garbage collection
private readonly List<JavaScriptNativeFunction> _jsNativeFunctions = new();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can use ConcurrentBag as you don't need a list with preserved order here

return MapJsPrimitivesToClr(value);
t = MapJsPrimitivesToClr(value);

return t;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can be inlined

var runner = new ChakraCoreRunner();
Assert.Throws<ArgumentException>(() => runner.Register(new HelperObject(), "x"));

runner.Dispose();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to explicit Dispose, can be inside using stmt

@medegor44 medegor44 force-pushed the ChakraCore_multithreading branch from 85d2d69 to b545e00 Compare October 18, 2021 11:12
@medegor44 medegor44 merged commit e96cf9b into master Oct 18, 2021
@medegor44 medegor44 deleted the ChakraCore_multithreading branch October 18, 2021 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants