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

Think about reloading code in multithreaded app #3

Open
ddovod opened this issue Jan 7, 2019 · 2 comments
Open

Think about reloading code in multithreaded app #3

ddovod opened this issue Jan 7, 2019 · 2 comments

Comments

@ddovod
Copy link
Owner

ddovod commented Jan 7, 2019

No description provided.

@ddovod ddovod mentioned this issue Jan 12, 2019
@Hexlord
Copy link

Hexlord commented Oct 3, 2020

What are your general thoughts on the ways to accomplish the task? How about providing your library all the mutexes of all extra threads, so tryReload event locks on all of them before proceeding?

@ddovod
Copy link
Owner Author

ddovod commented Oct 3, 2020

Not sure about this approach, only as a dirty hack. Strictly speaking, you should avoid any threads from executing code at all, so even if you wait on locked mutex, there's a possibility of SIG_ILL during code reload. It is much smaller but it still exists.

More general one involves some external tools like ptrace or signals or smth else. I didn't investigate it deeper, but there's no api on linux similar to SuspendThread on Windows, so we cannot suspend thread of current process from within this process. Probably the general solution leads to launch the application from inside a "manager" process which also runs all code-reload-related tasks.
That's my general thoughts.

Talking about "hacky" version, you can try to pause your threads (lock your mutexes) inside ILiveListener::onCodePreLoad() function and resume (unlock) in ILiveListener::onCodePostLoad(). I've never tried this for such scenario, but I guess it should work most of the times.

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