mirror of https://github.com/adamdruppe/arsd.git
more timer utility stuff
This commit is contained in:
parent
15491784cf
commit
4b91ff49b5
18
cgi.d
18
cgi.d
|
@ -5662,7 +5662,13 @@ final class BasicDataServerImplementation : BasicDataServer, EventIoServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/++
|
/++
|
||||||
|
See [schedule] to make one of these. You then call one of the methods here to set it up:
|
||||||
|
|
||||||
|
---
|
||||||
|
schedule!fn(args).at(DateTime(2019, 8, 7, 12, 00, 00)); // run the function at August 7, 2019, 12 noon UTC
|
||||||
|
schedule!fn(args).delay(6.seconds); // run it after waiting 6 seconds
|
||||||
|
schedule!fn(args).asap(); // run it in the background as soon as the event loop gets around to it
|
||||||
|
---
|
||||||
+/
|
+/
|
||||||
struct ScheduledJobHelper {
|
struct ScheduledJobHelper {
|
||||||
private string func;
|
private string func;
|
||||||
|
@ -5684,6 +5690,10 @@ struct ScheduledJobHelper {
|
||||||
void at(DateTime when, immutable TimeZone timezone = UTC()) {
|
void at(DateTime when, immutable TimeZone timezone = UTC()) {
|
||||||
consumed = true;
|
consumed = true;
|
||||||
|
|
||||||
|
auto conn = ScheduledJobServerConnection.connection;
|
||||||
|
import std.file;
|
||||||
|
auto st = SysTime(when, timezone);
|
||||||
|
auto jobId = conn.scheduleJob(1, cast(int) st.toUnixTime(), thisExePath, func, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/++
|
/++
|
||||||
|
@ -5692,6 +5702,9 @@ struct ScheduledJobHelper {
|
||||||
void delay(Duration delay) {
|
void delay(Duration delay) {
|
||||||
consumed = true;
|
consumed = true;
|
||||||
|
|
||||||
|
auto conn = ScheduledJobServerConnection.connection;
|
||||||
|
import std.file;
|
||||||
|
auto jobId = conn.scheduleJob(0, cast(int) delay.total!"seconds", thisExePath, func, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/++
|
/++
|
||||||
|
@ -5701,19 +5714,20 @@ struct ScheduledJobHelper {
|
||||||
+/
|
+/
|
||||||
void asap() {
|
void asap() {
|
||||||
consumed = true;
|
consumed = true;
|
||||||
//delay(0);
|
|
||||||
auto conn = ScheduledJobServerConnection.connection;
|
auto conn = ScheduledJobServerConnection.connection;
|
||||||
import std.file;
|
import std.file;
|
||||||
auto jobId = conn.scheduleJob(0, 1, thisExePath, func, args);
|
auto jobId = conn.scheduleJob(0, 1, thisExePath, func, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/+
|
||||||
/++
|
/++
|
||||||
Schedules the job to recur on the given pattern.
|
Schedules the job to recur on the given pattern.
|
||||||
+/
|
+/
|
||||||
version(none)
|
|
||||||
void recur(string spec) {
|
void recur(string spec) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
+/
|
||||||
}
|
}
|
||||||
|
|
||||||
private immutable void delegate(string[])[string] scheduledJobHandlers;
|
private immutable void delegate(string[])[string] scheduledJobHandlers;
|
||||||
|
|
Loading…
Reference in New Issue