Announcing libasync, a cross-platform D event loop

Suliman via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 28 11:33:27 PDT 2015


> Hmm, sorry that would be g_evl.loop(10.seconds) or 
> getThreadEventLoop().loop(10.seconds). I use the vibe.d driver 
> most often.

I changed paths to hardcoded to prevent issue with them, but next 
code after run only create "hey" folder and nothing more. No 
files in it:

{

	void dirWatcher()
	{
		auto g_watcher = new 
AsyncDirectoryWatcher(getThreadEventLoop());
		g_watcher.run({
			DWChangeInfo[1] change;
			DWChangeInfo[] changeRef = change.ptr[0..1];
			while(g_watcher.readChanges(changeRef)){
				writeln(change);
			}
		});
		g_watcher.watchDir(".");
		AsyncTimer tm = new AsyncTimer(getThreadEventLoop());
		tm.duration(1.seconds).run({
			writeln("Creating directory ./hey");
			mkdir(`D:\code\DirWathcher\hey`);
			assert(g_watcher.watchDir(`D:\code\DirWathcher\hey`));
			tm.duration(4.seconds).run({
				writeln("Writing to ./hey/tmp.tmp for the first time");
				std.file.write(`D:\code\DirWathcher\hey\tmp.tmp`, "some 
string");
				tm.duration(100.msecs).run({
					writeln("Removing ./hey/tmp.tmp");
					remove(`D:\code\DirWathcher\hey\tmp.tmp`);
				});
			});
		});
		getThreadEventLoop().loop(10.seconds);
	}

dirWatcher();
destroyAsyncThreads();

}


--------------
And how to detect if some there was some manipulation inside 
monitoring folder? How I can recive name of file that was added 
to folder?




More information about the Digitalmars-d mailing list