On Sun, 26 Jan 2014 04:44:31 GMT, Etienne Cimon wrote:

The formatting was too messed up, I sent with ThunderBird :/ Here's the clean version

void RequestHandler(HTTPServerRequest req, HTTPServerResponse res){
	alias ConcurrTuple = Tuple!(string, "name", bool, "auth", Variant[Variant], "dbrow");
	SomeController ctl;
	auto obj = concurrently!ConcurrTuple(
		{ return redis.get!string("name"); }
		toDelegate(&ctl.isAuth),
		{
			auto conn = pdb.lockConnection();
			auto cmd = new PGCommand(conn, "SELECT * FROM users WHERE userid=" ~ params.uid);
			auto result = cmd.executeQuery;
			return result;
	});
	// unblock here
	auto name = obj.name;
	auto authentified = obj.auth;
	auto userInfo = obj.dbrow;
}

Maybe it was just a suboptimal example, but since I/O should usually use async I/O, simply using runTask instead of runWorkerTask should suffice here, so no Isolated or shared would be necessary.

But a very similar and slightly more general concept are "promises" or "futures". Those in two flavors - one for normal tasks and one for worker tasks - would be a valuable addition for vibe.core.concurrency for sure. I didn't use them much in practice personally, but they are also a very nice way to add concurrency to an existing code base.