Hello, this is my first post on this mailing list!

i am currently trying to code some sort of very basic multi-agent in 
ruby (just to
test some idea)

each agent run its own thread, and send message to others with some
sort of mailing system (i actually defined a message class, and uses queues
to be thread safe...)

i am actually asking for some advice on several issue.

1st question
the message is constructed by one agent, wich then ask my "kernel"to 
transmit
it to one or multiples other agents (yet other threads). If i just want 
to be on the
safe side, i just duplicate everything when the message is transmitted...
however, it is not really very efficient...could i implement some sort 
of automatic
duplicate on write (actually using the freezing of the message), or any 
other ideas?

here an example definition of a very basic message class without duplication

class Message

  def get_value(key)
    @champs[key.to_s])
  end
 
  def set_value(key, value)
    @champs[key.to_s]= value.to_s
  end

  def initialize()
    @champs = Hash.new
  end

  def dup
    msg = Message.new
    @champs.each { |key, value| msg.set_value(key, value.dup)}
    return msg
  end

  def to_s
    str = "----message----\n"
    @champs.each { |key, value| str += "#{key} ===> #{value}\n" unless 
key == "binary"}
    str += "---------------"
  end

  def freeze
    @champs.each { |key, value| value.freeze}
    @champs.freeze
    super()
  end
end

this example will (i think) simply raise an exception if an agent try to 
alter
anything in a message frozen (i freeze them in the "kernel", just before 
dispatching
them...)


2nd question
is there some simple ways to do scheduling with the agent/threads, 
particularly
is there a way to get some sort of information on cpu/memory consumed by 
one
thread/agent

i have a lot more other questions (particularly on runtime class/code 
creation),
but lets begin with the more basic stuff :)


Thanks,

vincent