- Added a Task which represents the work done by a Promise
This commit is contained in:
Tristan B. Velloza Kildaire 2023-03-03 17:30:33 +02:00
parent 2f57083760
commit 9271fabfa9
1 changed files with 47 additions and 0 deletions

47
source/eventy/task.d Normal file
View File

@ -0,0 +1,47 @@
module eventy.task;
/**
* Task
*
* A task is the unit of execution that a promise is
* to carry out.
*/
public abstract class Task
{
public abstract Result worker();
public final Result doTask()
{
return null;
}
}
/**
* SimpleTask
*
* A task that returns an empty result
*/
public final class SimpleTask : Task
{
// TODO: Put worker field here
// TODO: Take in a lambda that takes in no arguments and executes something which returns void
this(int x)
{
}
// TODO: worker calls it
public override Result worker()
{
// TODO: Make a result
Result result;
// TODO: Call worker-field here
// TODO: You must handle errors and set `result` accordingly
return result;
}
}