Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected - Transient memory is bound to threadlocal, thus shared by two simulator instances #208

Open
martinpaljak opened this issue Aug 3, 2023 · 0 comments
Assignees

Comments

@martinpaljak
Copy link

martinpaljak commented Aug 3, 2023

The way transient memory is handled, is not as expected.

Making two simulator instances and sending commands to each other, right now the state is shared, as transient memory seems to come from a threadlocal for some reason.

private static final ThreadLocal<SimulatorRuntime> currentRuntime = new ThreadLocal<SimulatorRuntime>();

The result is that apple A gets the same state as applet B for transient arrays:

return SimulatorSystem.instance().getTransientMemory().makeByteArray(length, event);

because the instance() is coming from threadlocal:

public static SimulatorRuntime instance() {
SimulatorRuntime simulatorRuntime = currentRuntime.get();

What to do (other than have multiple threads), I'd say this is a bug, threading would mean concurrency, but I access to instances sequentially.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants