Bartosz asks What’s Wrong with the Th
Steven Schveighoffer
schveiguy at yahoo.com
Thu Jul 9 10:05:39 PDT 2009
On Thu, 09 Jul 2009 11:36:05 -0400, Bartosz Milewski
<bartosz-nospam at relisoft.com> wrote:
> Sean Kelly Wrote:
>
>> It would be trivial to implement spawn on top of the Thread object.
>
> Not so trivial, as I would like the spawn function to be a variadic
> template.
How is that not trivial? Or at least less trivial than implementing
Thread on top of spawn? All Thread does is abstract the OS' threading
mechanism, which you have to deal with anyway. As Sean pointed out, it
doesn't even require you to inherit from Thread (as I thought previously)
to make a new thread.
>
>> And
>> the reverse would work as well, though it would be less practical.
>> After
>> all, some data must be used to represent a thread even with the spawn
>> model, and it would be silly to graft a thread abstraction a few layers
>> above this.
>
> I didn't discuss the details of spawn, but I see it as returning a
> ThreadHandle struct holding the ID and providing methods that operate on
> the thread--essentially all the Thread methods except run.
Where do the static functions go? i.e. sleep, opApply, etc.
-Steve
More information about the Digitalmars-d
mailing list