-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testscript.d
executable file
·43 lines (32 loc) · 909 Bytes
/
testscript.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env dub
/+ dub.sdl:
name "rockhopper-testing-script"
dependency "rockhopper" path="."
dependency "eventcore" version="~>0.9.29"
+/
module testscript;
// this script is used for testing rockhopper, and can either be ran with `./testscript.d`, or `dub testscript.d`
import std.stdio;
import std.datetime : dur, MonoTime;
import rockhopper.core;
import rockhopper.rhapi;
import eventcore.core : eventDriver;
import core.thread.osthread : Thread;
mixin rhMain!({
import rockhopper.rhapi.file;
import std.string : representation, assumeUTF;
import std.socket : parseAddress;
import eventcore.driver : ConnectStatus, IOStatus;
auto p = Pipe.create();
auto wg = FWaitGroup(2);
spawn({
p.readStream.rawRead(15).assumeUTF.writeln; // only reads 4
wg.done();
});
spawn({
sleep(dur!"msecs"(500));
p.writeStream.rawWrite("test".representation);
wg.done();
});
wg.wait();
});