Skip to content

Nested task spawning broken #37

Closed
Closed
@rob-cohen

Description

@rob-cohen

When I use nested tasks with async::spawn() and async::get(), the synchronization doesn't work properly. This happens pretty consistently, and I am forced to never spawn tasks from tasks, which can be very limiting.

In the example below, some of the get()s will return before the work has completed, causing bugs.

Aside from this, the library is very convenient and works well.

Thanks!
Rob

void Function1()
{
	async::task<void> tasks[100];
	for (int t=0; t<100; t++)
	{
		tasks[t] = async::spawn([=]
		{
			Function2();
		});
	}

	for (int t=0; t<100; t++)
		tasks[t].get();
}

void Function2()
{
	async::task<void> tasks[100];
	for (int t=0; t<100; t++)
	{
		tasks[t] = async::spawn([=]
		{
			DoWork();
		});
	}

	for (int t=0; t<100; t++)
		tasks[t].get();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions