Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
JsPool recycle is not thread safe #36
JsPool.Recycle() method is not thread safe because DisposeAllEngines() is not thread safe:
Check the simulation of this scenario in a unit test: https://github.com/benokit/JSPool/blob/master/tests/JSPool.Tests/JsPoolRecycleTests.cs
Remove _metadata entirely. Add EngineMetada property to PooledObject class.
referenced this issue
Dec 13, 2018
I didn't go with the "lock" solution. It is not that simple. You would have to use the same lock object for three branches of execution: recyle, create engine and return engine, which means that "create engine" and "return engine" would undesirably lock each other. Moreover, because _availableEngines is protected you don't have control of how it will be (ab)used in the derived class.