Announcing libasync, a cross-platform D event loop

Suliman via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 28 09:57:42 PDT 2015


It's particularity of unit-test blocks, or why function are 
specified without return type like:

g_evl = getThreadEventLoop();


Also next code that I take from example after run absolutely do 
not do nothing:

void main()
{

	auto g_evl = getThreadEventLoop();
	auto g_cbCheck = new shared bool[19];

	auto g_watcher = new AsyncDirectoryWatcher(g_evl);
	g_watcher.run({
		DWChangeInfo[1] change;
		DWChangeInfo[] changeRef = change.ptr[0..1];
		while(g_watcher.readChanges(changeRef)){
			g_cbCheck[18] = true;
			writeln(change);
		}
	});
	g_watcher.watchDir(".");
	AsyncTimer tm = new AsyncTimer(g_evl);
	tm.duration(1.seconds).run({
		writeln("Creating directory ./hey");
		mkdir("./hey");
		assert(g_watcher.watchDir("./hey/"));
		tm.duration(1.seconds).run({
			writeln("Writing to ./hey/tmp.tmp for the first time");
			std.file.write("./hey/tmp.tmp", "some string");
			tm.duration(100.msecs).run({
				writeln("Removing ./hey/tmp.tmp");
				remove("./hey/tmp.tmp");
			});
		});
	});


}


More information about the Digitalmars-d mailing list