Async await problem solved

RSY rsy_881 at gmail.com
Fri Dec 11 11:48:45 UTC 2020


On Wednesday, 9 December 2020 at 09:16:31 UTC, aberba wrote:
> It's been there for a while.
>
>> This library provides a very easy-to-use async/await library 
>> for D. It consists of only three functions: async, await, and 
>> startScheduler. The library is build on top of D's fibers and 
>> allows for easier cooperative multitasking.
>
> import std.stdio;
>
> int calculateTheAnswer() {
> 	import core.thread : Thread;
> 	Thread.sleep(5.seconds);
> 	return 42;
> }
>
> void doTask() {
> 	writeln("Calculating the answer to life, the universe, and 
> everything...");
> 	int answer = await(calculateTheAnswer());
> 	writeln("The answer is: ", answer);
> }
>
> void main() {
> 	startScheduler({
> 		doTask();
> 	});
> }
>
> https://code.dlang.org/packages/dawait

nice library! thanks for sharing!


More information about the Digitalmars-d mailing list