Issue #506: task_isolation - rebase feature on the new branch, add unit tests, add Lazy wrapper by olologin · Pull Request #676 · taskflow/taskflow · GitHub
Skip to content

Issue #506: task_isolation - rebase feature on the new branch, add unit tests, add Lazy wrapper#676

Open
olologin wants to merge 1 commit into
taskflow:masterfrom
ModuleWorks:task_isolation
Open

Issue #506: task_isolation - rebase feature on the new branch, add unit tests, add Lazy wrapper#676
olologin wants to merge 1 commit into
taskflow:masterfrom
ModuleWorks:task_isolation

Conversation

@olologin

@olologin olologin commented Apr 9, 2025

Copy link
Copy Markdown

Solves #506
Of course I just show my changes, and I expect some improvements must be made to upstream this. Let me know if you see some area for improvement.
Also, I had to rebase these changes from last release branch, so maybe I missed something. But for our internal usage (which is mostly Lazy class) it works fine. We did not see significant slowdowns because of additional operations in scheduler yet.

Would be great to upstream this eventually.

Brief explanation of how this works: #506 (comment)

@bradphelan

bradphelan commented Apr 10, 2025

Copy link
Copy Markdown
Contributor

@tsung-wei-huang

Copy link
Copy Markdown
Member

Thank you very much for this pull request - let me look into this and see how we can make it better!

@olologin

olologin commented Apr 17, 2025

Copy link
Copy Markdown
Author

Not sure about the implementation, but regarding API:
I think it would be better to get rid of Executor::isolate method and allow user to use TaskArenaApplierRAII directly (maybe with better name).

This way user can implement some kind of cooperative mutex locking that does not block the calling thread and instead runs corun_until until mutex is available.
Basically it would be an alternative like

taskflow::Executor ex;
std::mutex m;
...
taskflow::scoped_lock l(m, ex); // If m.lock() succeeds - enter new task arena for the current thread, if not - ex.corun_until until m.lock() succeeds.

// Code that requires single-threaded execution
...

@tsung-wei-huang

tsung-wei-huang commented May 7, 2025

Copy link
Copy Markdown
Member

@tsung-wei-huang tsung-wei-huang added the enhancement New feature or request label May 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants