www.digitalmars.com         C & C++   DMDScript  

D - Function Pointers and Threads

reply "Brent Schartung" <bschartung home.com> writes:
I hope there are plans for D to one day support threads, hopefully as part
of a "Standard Library".  Well, my question is, suppose I wanted to spawn a
thread, or have a function spawn 'n' threads, or something more complicated.
Suppose I want to be ble to pass the thread starting function as a parameter
to my function, as well as the params to be passed to that thread function.
How exactly would I do that, or does that have yet TBA?

Speaking of standard libraries, I think that's one thing that makes Java so
wonderful--I have one source of documentation for how to write a socket for
any platform!  (Unfortantely, I have to write it in Java, though.)  If we
deny the use of header macros, we can't rely on #ifdef WIN32 #include
<winsock2.h> #else....., so standard libs are a must, i think!

 - Brent
Aug 17 2001
parent reply Russell Bornschlegel <kaleja estarcion.com> writes:
Brent Schartung wrote:
 
 I hope there are plans for D to one day support threads, hopefully as part
 of a "Standard Library".  Well, my question is, suppose I wanted to spawn a
 thread, or have a function spawn 'n' threads, or something more complicated.
 Suppose I want to be ble to pass the thread starting function as a parameter
 to my function, as well as the params to be passed to that thread function.
 How exactly would I do that, or does that have yet TBA?
I suspect you have to write a D prototype for a thread spawn function provided by the OS or by a C-language library. D's attribute system makes this pretty feasible. Ditto standard libraries -- once the D compiler is stable, someone will want to write a wrapper for the C standard library and for the Windows API. -Russell B
Aug 17 2001
parent reply "Walter" <walter digitalmars.com> writes:
One think I'm bad at is library design. D at the moment has no libraries
beyond the compiler helper functions. One of the great strengths of Java is
its class library. D needs something like that too.

And yes, D will have good support for multithreaded programming, with
synchronized statements and synchronized functions.

-Walter

Russell Bornschlegel wrote in message <3B7DB06F.1698FD66 estarcion.com>...
Brent Schartung wrote:
 I hope there are plans for D to one day support threads, hopefully as
part
 of a "Standard Library".  Well, my question is, suppose I wanted to spawn
a
 thread, or have a function spawn 'n' threads, or something more
complicated.
 Suppose I want to be ble to pass the thread starting function as a
parameter
 to my function, as well as the params to be passed to that thread
function.
 How exactly would I do that, or does that have yet TBA?
I suspect you have to write a D prototype for a thread spawn function provided by the OS or by a C-language library. D's attribute system makes this pretty feasible. Ditto standard libraries -- once the D compiler is stable, someone will want to write a wrapper for the C standard library and for the Windows API. -Russell B
Aug 17 2001
parent c. keith ray <c._member pathlink.com> writes:
In article <9lknn2$2sig$1 digitaldaemon.com>, Walter says...
One think I'm bad at is library design. D at the moment has no libraries
beyond the compiler helper functions. One of the great strengths of Java is
its class library. D needs something like that too.
My ideal language would easily link to Cocoa / Foundation / GnuStep, Java, Python, Smalltalk, Ruby, etc., while still enabling me to write twain plugins and other low-level non-application code. The Cocoa / Foundation / GnuStep class libraries are worth looking into as a model of good library design. The GnuStep library is GPLed, and the Foundation framework code (in C) is available via the BSD license in Apple's Darwin open-source project. C. Keith Ray <http://homepage.mac.com/keithray/resume2.html> <http://homepage.mac.com/keithray/xpminifaq.html>
Apr 29 2002