Class: Pione::Agent::TupleSpaceProvider

Inherits:
BasicAgent
  • Object
show all
Defined in:
lib/pione/agent/tuple-space-provider.rb

Overview

TupleSpaceProvider is an agent that provides a URI of tuple space as notification messages.

Instance Attribute Summary

Attributes inherited from BasicAgent

#chain_threads

Instance Method Summary collapse

Methods inherited from BasicAgent

agent_type, inherited, set_agent_type, #start, #start!, #states, #terminate, #terminated?, #transit, #wait_until, #wait_until_after, #wait_until_before, #wait_until_terminated

Methods included from StateTransitionSingletonMethod

#chain, #define_exception_handler, #define_transition, #exception_handler, #start, #transition_chain

Constructor Details

#initialize(uri, targets = Global.notification_targets) ⇒ TupleSpaceProvider

Returns a new instance of TupleSpaceProvider.

Parameters:

  • provider (URI)

    URI of the tuple space

  • targets (Array<URI>) (defaults to: Global.notification_targets)

    target URIs



16
17
18
19
20
21
22
# File 'lib/pione/agent/tuple-space-provider.rb', line 16

def initialize(uri, targets=Global.notification_targets)
  super()
  @targets = targets
  @notification = Notification::Message.new(
    "TUPLE_SPACE_PROVIDER", "TUPLE_SPACE", {"front" => uri}
  )
end

Instance Method Details

#transit_to_send_messageObject

transitions



39
40
41
# File 'lib/pione/agent/tuple-space-provider.rb', line 39

def transit_to_send_message
  Notification::Transmitter.transmit(@notification, @targets)
end

#transit_to_sleepObject



43
44
45
# File 'lib/pione/agent/tuple-space-provider.rb', line 43

def transit_to_sleep
  sleep 5
end