D2 std.thread and ThreadAddr

Sean Kelly sean at invisibleduck.org
Mon May 3 10:20:32 PDT 2010


fawcett at uwindsor.ca Wrote:
> 
> As a side-question: it considered bad form for a D library to have
> platform-specific functionality? E.g., if for some reason Windows
> didn't have any function for getting the current thread-id, is there a
> convention that the D library shouldn't offer a "currentID()" function
> at all, for portability reasons?

Good question.  One reason for not exposing the platform-specific threadId in addition to it being platform-specific is that it may allow operations that aren't supported in D.  For example, you could explicitly terminate the thread, etc.  I figure if you have a need to do something like this then it's reasonable to expect that you get the thread id yourself using pthread_this, etc.  I can see some justification for exposing ops that accept a thread ID if it's useful for C integration (thread_attachThis, for example, might have a thread_attachById analog), but that's really it.


More information about the Digitalmars-d mailing list