Functional Muti-threading
janderson
askme at me.com
Sun Jan 21 23:28:58 PST 2007
janderson wrote:
> Here's one idea about how D could help support multi-threading. What if
> you could specify which functions where thread-able. ie:
>
> threadable int foo(int X)
> {
> ...
> }
>
> void bar()
> {
> int a = 0;
> int array[3];
> x[0] = foo(a); //Separate worker thread
> x[1] = foo(a); //Separate worker thread (or could be main thread)
> x[2] = foo(a); //Main thread
> //Would sleep here until things are done
> }
>
>
> What do you think?
Here's an extension to the idea. It would be good to have an "un-pure",
"!pure" or "!threadable" functions as well. That way if you included an
"un-pure" function in an pure function the compiler would give an error.
If an included function was not marked un-pure the user would have
to face the side-effect consequences at run-time.
-Joel
More information about the Digitalmars-d
mailing list