dawait ~master
A simple to use async/await library
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
dawait - A simple to use async/await library
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.
Functionality
Function | Description |
---|---|
startScheduler(void delegate() callback) | Starts the scheduler with an initial task. |
async(void delegate() callback) | Runs the given delegate in a separate fiber. |
await(lazy T task) | Runs the expression in a separate thread. Once the thread has completely, the result is returned. |
Code Example
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();
});
}
- ~master released 4 years ago
- seeseemelk/dawait
- Boost
- Copyright © 2020, Sebastiaan de Schaetzen
- Authors:
- Dependencies:
- fluent-asserts, silly
- Versions:
-
0.1.1 2020-Apr-06 0.1.0 2020-Apr-03 ~master 2020-Apr-03 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
29 downloads total
-
- Score:
- 1.4
- Short URL:
- dawait.dub.pm