/CoroutineScheduler

Low allocation coroutines with tightly controlled concurrency

Primary LanguageC#MIT LicenseMIT

Logo

CoroutineScheduler

CoroutineScheduler CoroutineScheduler.Core
Codecov Mutation testing score

Low allocation coroutines with tightly controlled concurrency.

Usage

Add the following to your Directory.Build.props or csproj:

<ItemGroup>
  <PackageReference Include="CoroutineScheduler" Version="x.y.z" />
</ItemGroup>
using CoroutineScheduler;

var scheduler = new Scheduler();

// spawn a coroutine
scheduler.SpawnTask(MyCoroutine);


while (true)
	scheduler.Resume();

async Task MyCoroutine()
{
	int i = 0;
	while (true)
	{
		Console.WriteLine($"Hello {i++}");
		await scheduler.Yield();
	}
}