June 29, 2011
On 2011-06-29 13:59, Andrej Mitrovic wrote:
> Is there any way a newly spawned thread can get the Tid of the thread that spawned it, basically its parent? I'd prefer that over using this:
> 
> __gshared mainThread; // so workThread can access it
> 
> {
> mainThread = thisTid();
> auto workThread = spawn(&MidiThread); // local
> }

Usually what you do is give the parent's Tid as an argument to spawn. So, in this case, MidiThread would have a parameter of type Tid, and you'd change your code to

auto spawnedTid = spawn(&MidiThread, thisTid());

- Jonathan M Davis
June 29, 2011
I think spawn() had some bugs with not verifying the correct number of
arguments. I think there was a pull for that (or at least a bugzilla
entry). But this can work for me, thanks.