Idea for Threads

Craig Black cblack at ara.com
Sat May 12 22:59:06 PDT 2007


> This is an interesting idea, however the limitations for "threadsafe"
> code would be:
>
> * no reference type arguments to the "threadsafe" function

What if the references were read only?

> * no synchronized statements

Why not?

> * no use of function pointers / delegates

Because a threadsafe function shouldn't call a non threadsafe
function, right? Perhaps it would be possible to have threadsafe
delegates that could only be assigned with threadsafe functions.

> * no non-final class function calls

What do you mean by non-final?  Do you mean no virtual function calls?
Does this have something to do with non-threadsafe functions being
prohibited?

> * void pointers would require quite advanced compiler support

void pointers should probably be avoided.

> * due to the current GC implementation:
>     no non-scope allocations, no .length changes
> * as a consequence of the GC issue:
>     no reference type return statement from the "threadsafe" function
> * the "threadsafe" function has to be
>     1) at module level or
>     2) a "static" struct function or
>     3) a "final static" class function

Perhaps it could be a local member function if access to its
class data members was read only.

>
> Most likely some restrictions are missing but this should give you an
> idea.

It's a good start.

> Some of those restrictions only apply to the top level "threadsafe"
function.
> Depending on the sophistication of the compiler some limitation for
> functions called by the top level one might be lifted.

Not sure what you mean.

-Craig





More information about the Digitalmars-d mailing list