Bartosz asks What’s Wrong with the Th

Steven Schveighoffer schveiguy at yahoo.com
Thu Jul 9 10:02:55 PDT 2009


On Thu, 09 Jul 2009 08:48:45 -0400, Sean Kelly <sean at invisibleduck.org>  
wrote:

> Even run isn't supposed to be overridable, as it's a private method.   
> This
> works only because of a compiler bug.

whoa!  I didn't realize that!  Why would you ever inherit from Thread  
(even as the doc says, call super(&run) in the constructor)?  That is,  
should Thread really be a class, since all it does is contain context data?


> It would be trivial to implement spawn on top of the Thread object.  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.


The data is already a reference (i.e. phtread_thread_t is a reference as  
far as I know), so you are not actually containing the data, just a  
pointer to the data.  This could be easily returned from spawn.

As far as the context data that's *passed* to the thread that the user  
cares about, I don't think it makes a huge difference either way.

One other thing to note about changing the thread model -- It breaks  
future Tango (>=D2) compatibility, I'm not sure the Tango team wants to  
move to a different thread implementation.

-Steve



More information about the Digitalmars-d mailing list