Skip to content

Instantly share code, notes, and snippets.

@renestein
Created June 6, 2014 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renestein/95878c90b1d5a7a5bebe to your computer and use it in GitHub Desktop.
Save renestein/95878c90b1d5a7a5bebe to your computer and use it in GitHub Desktop.
using System;
using System.Runtime.CompilerServices;
using RStein.Async.Schedulers;
namespace RStein.Async.Examples.Coroutines
{
public class Coroutine : INotifyCompletion
{
private readonly IoServiceScheduler m_ioServiceScheduler;
public Coroutine(IoServiceScheduler ioServiceScheduler)
{
m_ioServiceScheduler = ioServiceScheduler;
}
public virtual bool IsCompleted
{
get
{
return false;
}
}
public void OnCompleted(Action continuation)
{
m_ioServiceScheduler.Post(continuation);
}
public virtual void Run()
{
m_ioServiceScheduler.Run();
}
public virtual Coroutine GetAwaiter()
{
return this;
}
public virtual void GetResult() {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment