vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

Template makeIsolated

Creates a new isolated object.

template makeIsolated(T, ARGS...) ;

Isolated objects contain no mutable aliasing outside of their own reference tree. They can thus be safely converted to immutable and they can be safely passed between threads.

The function returns an instance of Isolated that will allow proxied access to the members of the object, as well as providing means to convert the object to immutable or to an ordinary mutable object.

Contained Functions

makeIsolatedCreates a new isolated object.


import vibe.core.concurrency;
import vibe.core.core;

static class Item {
	double value;
	string name;

static void modifyItem(Isolated!Item itm)
	itm.value = 1.3;
	// TODO: send back to initiating thread

void test()
	immutable(Item)[] items;

	// create immutable item procedurally
	auto itm = makeIsolated!Item();
	itm.value = 2.4; = "Test";
	items ~= itm.freeze();

	// send isolated item to other thread
	auto itm2 = makeIsolated!Item();
	runWorkerTask(&modifyItem, itm2.move());
	// ...

Sönke Ludwig


© 2013-2014 RejectedSoftware e.K.


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.