[Issue 1966] New: Allow for Derived Thread Classes
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 1 06:04:16 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1966
Summary: Allow for Derived Thread Classes
Product: D
Version: 2.012
Platform: PC
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: bugzilla at digitalmars.com
ReportedBy: bcwhite at pobox.com
As far as I can tell, it's not possible to create a class derived from Thread
and have it apply to the main thread. This is because the "static void
thread_init()" function internally does a "new Thread()". Thus, if I want to
create a derived class, I must duplicate this function in it's entirety rather
than just call it as part of the derived "thread_init".
How about having the existing class take a single Thread parameter that
defaults to "null" and only allocate a new object if "null" is received.
public static void thread_init(Thread t = null)
{
if (t is null) {
t = new Thread();
}
...
}
I would then have my derived thread class define its own function like this...
public static void thread_init(MyThread t = null)
{
if (t is null) {
t = new MyThread();
}
Thread.thread_init(t);
...
}
--
More information about the Digitalmars-d-bugs
mailing list