Micro threads (tasklets) for async/await syntax

Topics: C# Language Design
Apr 4, 2014 at 12:44 PM
What about MicroThreads (mono tasklets) for async/await syntax?

so async methods wil be mutch cheaper and do not create additional memory allocations and exception handling will be very easy to introduce

http://mono-project.com/Continuations

When call async methods from sync context faramework pop micro stack from pool and async method use it for execution. On await it just switch from micro stack to real thread stack, and when continuation calls we just switch to suspended micro thread and go on. when async method awaits fo another asunc methd it just call it in microctack and all. All exceptions will be catched properly because this is stack.

No addtional memory allocations no compiler state machine generation, sync functions can be called inside async micro stack...

May be for back compatibility async micro stack can be marked as -> stack async in C#

private stack async void DoSomethingAsync( )
{
....
var fileData = stack await ReadFileAsync( );
....

}