abstract class ReactiveProtocol extends ProtocolImpl with ListenerUtils with Sending with Receiving with Tracing
Convenience class to replace ProtocolImpl with all common traits already mixed in.
A protocol that sits as a middle layer between application and network can extend this class, which provides all of the basic functionalities.
A subclass must provide an implementation to the methods Sending!.onSend and Receiving!.onReceive.
- Alphabetic
- By Inheritance
- ReactiveProtocol
- Tracing
- Receiving
- Sending
- Sender
- ListenerUtils
- Listener
- Receiver
- ProtocolImpl
- ProtocolUtils
- Protocol
- NamedEntity
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
ReactiveProtocol(config: ProcessConfig, nickname: String = "unnamed")
- config
configuration from the process to which the protocol instance is attached
- nickname
nickname of the protocol (aimed to be used for io)
Abstract Value Members
-
abstract
def
onReceive: PartialFunction[Event, Unit]
Implements the behavior of the protocol when receiving a message (or signal).
Implements the behavior of the protocol when receiving a message (or signal).
This must be defined in any concrete subclass. It is defined as a partial function taking a message as input and returning nothing.
Typically, the partial function will implement different behavior depending on the type of message being sent. For instance,
def onReceive = { case Token(from, _, _) if parent.isEmpty => parent = Some(from) children = (neighbors-from).toList DELIVER (Visit) visitNextChild() case Token(_, _, _) => visitNextChild() }
- Definition Classes
- Receiving
-
abstract
def
onSend: PartialFunction[Event, Unit]
Implements the behavior of the protocol when sending a message.
Implements the behavior of the protocol when sending a message.
This must be defined in any concrete subclass. It is defined as a partial function taking a message as input and returning nothing.
Typically, the partial function will implement different behavior depending on the type of message being sent. For instance,
def onSend = { case MutexClient.Request => want = true ; myTS = lc.time SEND(Request(me, ALL-me, myTS)) case MutexClient.Release => SEND(Ack(me, pendingAcks)) ackCount = 0 ; want = false ; pendingAcks = Set.empty }
- Definition Classes
- Sending
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from ReactiveProtocol to any2stringadd[ReactiveProtocol] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
-->(sender: Sender): Unit
Connects a new sender to this protocol.
Connects a new sender to this protocol.
- sender
the new sender to connect.
- Definition Classes
- ProtocolUtils
-
def
->[B](y: B): (ReactiveProtocol, B)
- Implicit
- This member is added by an implicit conversion from ReactiveProtocol to ArrowAssoc[ReactiveProtocol] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
lazy val
ALL: Set[PID]
set of all processes in the system.
set of all processes in the system.
- Attributes
- protected[this]
- Definition Classes
- ProtocolUtils
-
def
BROADCAST(m: BroadcastMessage): Unit
Broadcasts a message using the sender set in the initializer where the protocol is created.
-
def
DELIVER(m: Event): Unit
provides the message or signal to the application.
provides the message or signal to the application. The message or signal passed as argument will be delivered to any protocol that has registered (e.g., using the method ListenerUtils!.listenTo) for this type of message/signal to the dispatcher providing in receiver.
- m
the message or signal to deliver
- Definition Classes
- ReactiveProtocol → Sending
-
lazy val
N: Int
total number of processes running in the system.
total number of processes running in the system.
- Attributes
- protected[this]
- Definition Classes
- ProtocolUtils
-
def
SEND(m: Event): Unit
Sends a message using the sender set in the initializer where the protocol is created.
Sends a message using the sender set in the initializer where the protocol is created. If no sender was explicitly set, the message will be set directly through the network. The destination for the message is defined when the message is created.
- m
the message/signal to send
- Definition Classes
- ReactiveProtocol → Receiving
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
def
context: Some[PID]
- Definition Classes
- Protocol → NamedEntity
-
def
deliver(m: Event): Unit
- Definition Classes
- ReactiveProtocol → Receiving → Receiver
-
def
dispatcher: Dispatcher
dispatcher to be used when delivering messages.
dispatcher to be used when delivering messages. Typically, this is the default dispatcher of the process.
- returns
dispatcher for message delivery
- Definition Classes
- ProtocolImpl
-
def
ensuring(cond: (ReactiveProtocol) ⇒ Boolean, msg: ⇒ Any): ReactiveProtocol
- Implicit
- This member is added by an implicit conversion from ReactiveProtocol to Ensuring[ReactiveProtocol] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (ReactiveProtocol) ⇒ Boolean): ReactiveProtocol
- Implicit
- This member is added by an implicit conversion from ReactiveProtocol to Ensuring[ReactiveProtocol] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): ReactiveProtocol
- Implicit
- This member is added by an implicit conversion from ReactiveProtocol to Ensuring[ReactiveProtocol] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): ReactiveProtocol
- Implicit
- This member is added by an implicit conversion from ReactiveProtocol to Ensuring[ReactiveProtocol] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
eventTracer: EventTracer
- Definition Classes
- ProtocolImpl
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from ReactiveProtocol to StringFormat[ReactiveProtocol] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
val
id: ProtoID
identifier of the protocol.
identifier of the protocol.
- returns
identifier of the protocol
- Definition Classes
- ProtocolImpl → Protocol
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
listenTo(clazz: Class[_ <: Event]): Unit
called by the protocol to declare that it will listen to messages/event of the given type.
called by the protocol to declare that it will listen to messages/event of the given type.
class MyProtocol(...) extends ... with ListenerUtils { listenTo(classOf[MyMessage]) listenTo(MyAlarm.getClass) def onReceive = { case MyMessage(...) => ... case MyAlarm => ... } } object MyProtocol { case class MyMessage(...) extends UnicastMessage(...) case object MyAlarm extends Signal
- clazz
type of the message/event to listen to
- Attributes
- protected[this]
- Definition Classes
- ListenerUtils → Listener
-
lazy val
me: PID
identifier of the process in which the protocol is running.
identifier of the process in which the protocol is running.
- Attributes
- protected[this]
- Definition Classes
- ProtocolUtils
-
def
name: String
returns the name of the protocol
returns the name of the protocol
- returns
name of the protocol
- Definition Classes
- Protocol → NamedEntity
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
lazy val
neighbors: Set[PID]
set of processes that are direct neighbors to the process in which this instance of the protocol runs.
set of processes that are direct neighbors to the process in which this instance of the protocol runs.
- Attributes
- protected[this]
- Definition Classes
- ProtocolUtils
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
onError(e: Throwable): Unit
override this method to report on errors whens the protocol is forcibly terminated due to an an error or exception.
override this method to report on errors whens the protocol is forcibly terminated due to an an error or exception. The method should never use any of the communication methods such as send, receive, or deliver.
- Definition Classes
- Protocol
-
final
def
onFinish(): Unit
this method does nothing for reactive protocols; take downs should instead override the method onShutdown.
this method does nothing for reactive protocols; take downs should instead override the method onShutdown.
- Definition Classes
- ReactiveProtocol → Protocol
-
def
onShutdown(): Unit
override this method to perform take downs after all processes have finished and before the process shuts down.
override this method to perform take downs after all processes have finished and before the process shuts down.
- Definition Classes
- Protocol
-
def
out: PrintWriter
- Definition Classes
- ProtocolImpl
-
def
preStart(): Unit
override this method to perform initializations just before the process begins to run.
override this method to perform initializations just before the process begins to run.
- Definition Classes
- Protocol
-
def
process: PID
identifier of the process to which the protocol is attached.
identifier of the process to which the protocol is attached.
- returns
identifier of the process
- Definition Classes
- ProtocolImpl → Protocol
-
def
receiver: Receiver
receiver to which this protocol delivers messages.
receiver to which this protocol delivers messages. Typically, this is the message dispatcher of the process.
- returns
receiver to which messages are delivered
- Definition Classes
- ProtocolUtils
-
def
receiver_=(receiver: Receiver): Unit
sets a new receiver to which this protocol will deliver messages.
sets a new receiver to which this protocol will deliver messages. Normally, there is no need for the application programmer to use this, as the receiver is automatically set to a meaningful default value.
- receiver
new receiver to which messages will be delivered
- Definition Classes
- ProtocolUtils
-
def
send(m: Event): Unit
Used to request the protocol to send a given message.
Used to request the protocol to send a given message.
The function translates to a call to onSend in order to handle the message.
- m
the message to send
- Definition Classes
- ReactiveProtocol → Sending → Sender
-
def
sender: Sender
target sender that will handle Sending#send operations for this protocol.
target sender that will handle Sending#send operations for this protocol.
- returns
target sender
- Definition Classes
- ProtocolUtils
-
def
senderOpt: Option[Sender]
- Definition Classes
- ProtocolUtils
- def setTrace[A](obj: A, nameOfVariable: String*)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[A], arg1: ClassTag[A]): Unit
-
def
simpleName: String
- Definition Classes
- Protocol → NamedEntity
-
def
start(): Unit
override this method to perform initialization just as the process starts.
override this method to perform initialization just as the process starts.
- Definition Classes
- Protocol
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
system: NekoSystem
system in which the protocol is running.
system in which the protocol is running. This gives access to some general information about the system, such as the total number of processes.
- returns
the system in which the protocol runs.
- Definition Classes
- ProtocolImpl → Protocol
-
def
toString(): String
- Definition Classes
- ProtocolImpl → AnyRef → Any
-
val
tracer: EventTracer
- Attributes
- protected
- Definition Classes
- Tracing
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
→[B](y: B): (ReactiveProtocol, B)
- Implicit
- This member is added by an implicit conversion from ReactiveProtocol to ArrowAssoc[ReactiveProtocol] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc