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

thread wainting for task to end should not run another task #42

Open
MatthieuTexier opened this issue Jan 13, 2021 · 5 comments
Open

thread wainting for task to end should not run another task #42

MatthieuTexier opened this issue Jan 13, 2021 · 5 comments

Comments

@MatthieuTexier
Copy link

MatthieuTexier commented Jan 13, 2021

Hello, thank you for the nice lib.

I will try to describe my problem.
The default scheduler runs several tasks, says A and B
Task A creates a temporary scheduler and wait on it's internal tasks with when_all(A_tasks).wait()
The waiting thread runs task B and this leads to a mess as B cannot be called from A.
A thread waiting for a task to end should not run another task.

@MatthieuTexier MatthieuTexier changed the title when_all::wait run tasks from different scheduler thread waint for task end should not run another task Jan 13, 2021
@MatthieuTexier MatthieuTexier changed the title thread waint for task end should not run another task thread wainting for task to end should not run another task Jan 13, 2021
@zerodefect
Copy link
Contributor

Can you elaborate on this some more? I'm wondering if I've seen the same thing. Do you have any example code?

@Amanieu
Copy link
Owner

Amanieu commented Jan 18, 2021

The behavior of wait is controlled by the wait handler set by set_thread_wait_handler. Since A is running in the default scheduler thread pool it will use the handler set up by the thread pool and try to run other pending tasks from the default scheduler while waiting.

@MatthieuTexier
Copy link
Author

Thanks Amanieu, I will try to set the thread_wait_handler.

@kikaxa
Copy link

kikaxa commented Feb 15, 2024

Also, you really should use continuations (.then) if you use async patterns.
@MatthieuTexier do you need this task open any more?

@MatthieuTexier
Copy link
Author

Hi @kikaxa , yes I do.

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

4 participants