www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Microsoft Comega language

reply "Jeroen van Bemmel" <someone somewhere.com> writes:
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 */
  }
} 
Oct 05 2004
parent reply "Ivan Senji" <ivan.senji public.srce.hr> writes:
"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.

Oct 05 2004
next sibling parent reply someone somewhere.com writes:
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>
Oct 06 2004
parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
<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.

 threadpool rather than creating a new thread each time. One could think of
 attributes that say which threadpool to use (other than 'default'), and

 mechanism to declare which threadpools there are (and how many threads

 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>

Oct 06 2004
prev sibling parent "Lloyd Dupont" <ld NewsAccount.galador.net> writes:
 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.

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; }
Oct 06 2004