Skip to content

Instantly share code, notes, and snippets.

@renestein
Created June 2, 2014 12:45
Show Gist options
  • Save renestein/c647a1499fcc26f46f82 to your computer and use it in GitHub Desktop.
Save renestein/c647a1499fcc26f46f82 to your computer and use it in GitHub Desktop.
public class IoServiceScheduler : TaskSchedulerBase, IAsioTaskService
{
public const int REQUIRED_WORK_CANCEL_TOKEN_VALUE = 1;
public const int POLLONE_RUNONE_MAX_TASKS = 1;
public const int UNLIMITED_MAX_TASKS = -1;
private readonly ThreadLocal<IoSchedulerThreadServiceFlags> m_isServiceThreadFlags;
private readonly CancellationTokenSource m_stopCancelTokenSource;
private readonly BlockingCollection<Task> m_tasks;
private readonly object m_workLockObject;
private CancellationTokenSource m_workCancelTokenSource;
private volatile int m_workCounter;
public IoServiceScheduler()
{
m_tasks = new BlockingCollection<Task>();
m_isServiceThreadFlags = new ThreadLocal<IoSchedulerThreadServiceFlags>(() => new IoSchedulerThreadServiceFlags());
m_stopCancelTokenSource = new CancellationTokenSource();
m_workLockObject = new object();
m_workCounter = 0;
}
.....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment