Thread overview
Microsoft Comega language
Oct 05, 2004
Jeroen van Bemmel
Oct 06, 2004
Ivan Senji
Oct 06, 2004
someone
Oct 07, 2004
Ivan Senji
Oct 07, 2004
Lloyd Dupont
October 05, 2004
Maybe some people here find this interesting: http://research.microsoft.com/Comega/

in particular http://research.microsoft.com/Users/luca/Papers/Polyphony%20(TOPLAS).pdf describes some interesting constructs:

1. async PostEvent( EventData data ) { /* executed in separate thread */ }
2. public class Buffer {
  public String Get() & public async Put( string s ) {
    return s; /* Get synchronizes with Put, then this is executed */
  }
}


October 06, 2004
"Jeroen van Bemmel" <someone@somewhere.com> wrote in message news:cjv59a$ujl$1@digitaldaemon.com...
> Maybe some people here find this interesting: http://research.microsoft.com/Comega/
>
> in particular http://research.microsoft.com/Users/luca/Papers/Polyphony%20(TOPLAS).pdf describes some interesting constructs:
>
> 1. async PostEvent( EventData data ) { /* executed in separate thread */ }

Would this be the same as:
void PostEvent( EventData data )
{
    void _PostEvent( EventData data )
    {
        /* executed in separate thread */
    }
    Thread t = new Thread(&_PostEvent);
    t.start();
 }
?


> 2. public class Buffer {
>   public String Get() & public async Put( string s ) {
>     return s; /* Get synchronizes with Put, then this is executed */
>   }
> }

And if someone knows how the D code for this would look,
please post it and i will try to add that to the list of syntax extensions
i am working on.

>
>


October 06, 2004
In article <ck03od$1kd7$1@digitaldaemon.com>, Ivan Senji says...
>
>Would this be the same as:
>void PostEvent( EventData data )
>{
>    void _PostEvent( EventData data )
>    {
>        /* executed in separate thread */
>    }
>    Thread t = new Thread(&_PostEvent);
>    t.start();
> }

The above is correct but not optimal, the compiler could optimize and e.g. use a threadpool rather than creating a new thread each time. One could think of attributes that say which threadpool to use (other than 'default'), and some mechanism to declare which threadpools there are (and how many threads they contain)

Something like:

async( "ThreadPool1" ) PostEvent( /* params */ ) {
..
}

and a deployment descriptor like
<deployment>
<threadpool name="ThreadPool1" maxthreads="10" initialthreads="3"/>
</deployment>





October 07, 2004
>> 2. public class Buffer {
>>   public String Get() & public async Put( string s ) {
>>     return s; /* Get synchronizes with Put, then this is executed */
>>   }
>> }
>
> And if someone knows how the D code for this would look,
> please post it and i will try to add that to the list of syntax extensions
> i am working on.
>
I'm not that fluent in D, beside I think they play with stack and other low-level things. anyway a pseudo-code doing that would looks like that:

public class Buffer
{
    public string Get()
    {
        string s = (string) queue.Pop();
        return s;
    }
    public void Put(string s)
    {
        queue.Push(s);
    }
    // --- where queue:
    // 1. Push()/Pop() combination is thread safe
    // 2. Pop method wait until there is some data in it
    // 3. could be any kind of FIFO, LIFO, RandomOut collection
    Stack queue;
}


October 07, 2004
<someone@somewhere.com> wrote in message news:ck15mh$2m6k$1@digitaldaemon.com...
> In article <ck03od$1kd7$1@digitaldaemon.com>, Ivan Senji says...
> >
> >Would this be the same as:
> >void PostEvent( EventData data )
> >{
> >    void _PostEvent( EventData data )
> >    {
> >        /* executed in separate thread */
> >    }
> >    Thread t = new Thread(&_PostEvent);
> >    t.start();
> > }
>
> The above is correct but not optimal, the compiler could optimize and e.g.
use a
> threadpool rather than creating a new thread each time. One could think of attributes that say which threadpool to use (other than 'default'), and
some
> mechanism to declare which threadpools there are (and how many threads
they
> contain)

I don't want to make it optimal because i don't have time for it, i am just
thinking
about syntaxes that could be possible in D.

> Something like:
>
> async( "ThreadPool1" ) PostEvent( /* params */ ) {
> ..
> }
>
> and a deployment descriptor like
> <deployment>
> <threadpool name="ThreadPool1" maxthreads="10" initialthreads="3"/>
> </deployment>
>
>
>
>
>