[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: JCSP Advice anyone?
Hi Ruth, Bernhard and everyone,
I agree with Bernhard that you should take a look at the call-channel
concept - the only problem is that its a bit long winded to put
together. Ideally I wanted to extend the Java syntax in our (the now
expired Quickstone) JCSP compiler to do this much more simply, but we
had to stop work on it before we got that far. We did however write a
rather cool Java app to support code generation of complex call channel
servers in bulk, but I'm not sure how much use that'd be to Ruth as it
Another approach that might be worth considering is creating a call
channel interface using a proxy object in a similar way to the Hibernate
database library. Java Proxy objects allow you to dynamically create a
Java interface and respond to method invocations pro grammatically. I
don't even know if C# supports this, but I'd be surprised if it didn't.
It does however depend on how bothered you are about efficiency. It's
also a bit complicated - but more fun :). If you're feeling really
adventurous you could use reflection (and possibly method annotations)
to generate the necessary classes/interfaces statically at build time,
which would get around the efficiency problem...
One thing that'd might make things easier (i.e. less long-winded) might
be to write a class that extends CSProcess that just takes a delegate
and calls it in its run method. It'd then be easier to create processes
with less code - I have to admit I haven't fully thought this approach
through as I'm not really that familiar with delegates.
Also remember that you don't have to use Parallel or ProcessManager at
all if it's a real pain, you could just start threads in the normal C#
way - the CSP synchronization operations will still work.
Bernhard Sputh wrote:
below my suggestions on how to solve Your problem using JCSP.
On Thursday 15 December 2005 17:39, Ruth Ivimey-Cook wrote:
I'm new to using JCSP, and thought this might be a good place to ask for
help. If I was wrong in that thought, please forgive me...
Well there is a list called Java Threads, which I think centres around JCSP,
but with JCSP being close to Occam I think it is alright.
What I want to know is am I on the "right track", or is there a better way?
Well looking at the code You sent it looks like a perfect application of
Call-Channels (Look in the JavaDoc for the class jcsp.lang.One2OneCallChannel
there is very good explanation given, iirc). Internally they work with two
channel transactions but, for synchronisation, and data is passed directly.
The server process provides designated methods. When a call arrives the
server process acknowledges this and is put to sleep while these methods are
called in the context of the client process. The server process resumes after
the method call is completed.
The downside is that to use a call-channel one has to extend the call channel
class first to provide the methods You need. Apart from this necessary extra
work they are great. It is even possible to deliver exceptions from the
server to the client. Furthermore, the process placing the call does this by
simply placing a function call, not knowing about the ongoing channel
transactions at all.
Hope this helps, happy hacking ;-)