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

Fix broken shutdown if scheduling from event loop context #550

Merged
merged 2 commits into from
Jul 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/ocean/task/Scheduler.d
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,15 @@ final class Scheduler : IScheduler
{
if (this.state == State.Shutdown)
{
// Simply returning here would be generally sufficient to make sure
// no new tasks get added after shutdown. However, it is of some
// merit to try to kill everything as soon as possible thus
// scheduler kills the caller tasks on any attempt to schedule a new
// one.
auto caller_task = Task.getThis();
if (caller_task !is null)
caller_task.kill();
return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but it might be worth adding a comment as to why the calling task is killed if schedule is called during shutdown.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add

}

try
Expand Down