------extPart_000_0018_01C46589.F061E950
Content-Type: text/plain;
	charsetso-8859-1"
Content-Transfer-Encoding: 7bit


"zuzu" <sean.zuzu / gmail.com> schrieb im Newsbeitrag
news:a988e9f60407081357560a9592 / mail.gmail.com...

> On Thu, 8 Jul 2004 19:27:41 +0900, Robert Klemme <bob.news / gmx.net> wrote:

> one important aspect i have neglected to emphasize is the nature of
> flow-based (aka "agent") programming style in ruby.  see
> http://www.jpaulmorrison.com/fbp/index.shtml

"Flow based" seems to me just another name for "event driven" from what I
read so far.  It's a bit graph theory, a bit Petri Nets, a bit concurrency
theory - not nearly as sensational as the author tries to make us think.

> # how can ruby utilize the 4 CPU cores for this massively parallel
> bounded-buffer data-flow as a single unix process with only internal
> threading?

So basically what you want is, that Ruby makes use of native threads.  I
guess it would be much easier to implement a Ruby interpreter that uses
native threads than to make a Mach microkernel server.  And it's more
portable (i.e. POSIX threads).  This sounds a bit like the wrong hammer to
your problem.  But then again, I'm not a microkernel expert.

> one possible solution i thought of is to port the ruby interpreter as
> a Mach microkernel server, sitting beside the bsd "personality"
> server.  each object would be a Mach task while each function would be
> a Mach thread, and objects would communicate via Mach inter-process
> communication (IPC).  networking and filesystems can also be accessed
> through Mach.

IMHO making each object a mach task would be overkill.  You probably meant
each *component* (i.e. independent self contained processing unit as
described by Paul Morrison) should be a mach task.

Regards

    robert


PS: Attached some sample of what I understand from "flow based".

------extPart_000_0018_01C46589.F061E950
Content-Type: application/octet-stream;
	nameroc.rb"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filenameroc.rb"

#!/usr/bin/ruby

require 'thread'

class Processor
  class Terminator; end

  TERM_ASYNC  erminator.new
  TERM_SYNC  erminator.new

  attr_reader :incoming

  def initialize
    super
    @incoming  ueue.new
    @attached  ]
  end

  def start
    raise "Already Running" if running?

    @process  hread.new( incoming ) do
      until ( Terminator  ( item  ncoming.deq ) )
        begin
          process item
        rescue Exception e
          $stderr.puts e
        end
      end

      @attached.each do |pr|
        if TERM_ASYNC item
          pr.terminate
        else
          pr.terminate_and_wait
        end
      end
    end
  end

  def running?
    @process && @process.alive?
  end

  def terminate
    incoming.enq TERM_ASYNC
  end

  def terminate_and_wait
    incoming.enq TERM_SYNC
    join
  end

  def join
    @process.join if running?
  end

  protected
  def process(item)
    raise "Must be overridden"
  end
end


class Multiplier < Processor

  def attach(*processors)
    @attached.concat processors
    self
  end

  def remove(*processors)
    processors.each {|pr| @attached.delete pr}
    self
  end

  protected
  def process(item)
    send_all "[#{item}]"
  end

  def send_all(item)
    @attached.each do |pr|
      pr.incoming.enq item
    end
  end
end

p1  ultiplier.new
p2  rocessor.new
p3  rocessor.new
def p2.process(item) puts "processing 1 #{item.inspect}" end
def p3.process(item) puts "processing 2 #{item.inspect}" end

p1.attach p2, p3

p1.start
p2.start
p3.start

p1.incoming.enq "foo"
p1.terminate_and_wait


------extPart_000_0018_01C46589.F061E950--