spawn

fnTid spawn(F, T...)(F fn, T args) if (isSpawnable!(F, T))

Starts fn(args) in a new logical thread.

Executes the supplied function in a new logical thread represented by Tid. The calling thread is designated as the owner of the new thread. When the owner thread terminates an OwnerTerminated message will be sent to the new thread, causing an OwnerTerminated exception to be thrown on receive().

Parameters

fnThe function to execute.
argsArguments to the function.

Returns

A Tid representing the new logical thread.

Notes: args must not have unshared aliasing. In other words, all arguments to fn must either be shared or immutable or have no pointer indirection. This is necessary for enforcing isolation among threads.

Similarly, if fn is a delegate, it must not have unshared aliases, meaning fn must be either shared or immutable.