Greetings,
First of all, I'm not exactly sure how seriously to take the C-Omega project
(http://research.microsoft.com/Comega/). It appears to be a potential
glimpse into what C# 3.0 might become. It has had some press recently and I
have taken a small interest in it. Particularily, I am interested in the
embedded SQL-like syntax that it provides for accessing objects and to a
lessor extent (with regards to my interst in it) databases.
Somewhere along the line, after reading the docs, I learned that it supports
an inherent currency model for achieving parallism during execution of code.
While I like the idea, I don't like the implementation.
For example (just one of the many examples of how to implement concurrent
functionality):
public class Buffer { public async Put(string s); public string Get() &
Put(string s) { return s; }} Makes sense, but isn't, IMO clean.
Hence the purpose of this discussion. How do you think it should look?
What would make it easier and more C#-like?
My idea, perhaps, would be to have a syntax thus:
public class MyClass { public [static] parallel int DoSomething() { ...
return anInt; }}Perhaps at this point, it takes a similar syntax (but a
little different) to a delegate (regardless of whether it actually is
compiled as one):
public class BusinessObject { public void DoSomething() { MyClass
example = new MyClass(); IConcurrentResult icr1 = example.DoSomething();
.... int result = (int)icr1.SyncronizedResult; }}Perhaps even that syntax
isn't as clean, I'm hoping people can give other ideas. I'd like to explore
what people think and provide a pre-compiler for C# to prove the concept (or
change Rotor code to compile it directly). Perhaps we use a "concurrent"
keyword instead of "parallel"?
I was also thinking of inlining it thus:
public void DoSomething() { int[50000] x; int[50000] y; ... parallel
_longLoop for(j=0; j<50000; j++) { for (k=0; k<50000; k++) { y[k] =
k; } x[j] = j; } ... _longLoop.WaitOne(); ...
MessageBox.Show(x[500].ToString());}And as an alternate (personally, I like
the previous example better):
parallel for(j=0; j<50000; j++) { for (k=0; k<50000; k++) { y[k] =
k; } x[j] = j; } _longLoop;There are other things to concider, the
c-omega docs allow for reader-writer locks and so on which could easily be
addressed.
We can also have anonymous concurrency thus:
public void DoSomething() { ... parallel { int[50000] x; int[50000]
y; for(j=0; j<50000; j++) { for (k=0; k<50000; k++) { y[k] =
k; } x[j] = j; } UpdateDatabase(x, y); } ...}Assuming
C-Omega is indeed a glimpse into C# 3.0 and we were to get a concurrent
model for programming, how would you like to see the syntax for concurrency?
Thanks,
Shawn