package sl
This package contains the Scala DSL for Kompics.
It is recommended to import this as import se.sics.kompics.sl._
, since it
contains a number of implicit conversions and convenience methods that are
good to have in scope.
- Alphabetic
- By Inheritance
- sl
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
- package simulator
The Kompics Simulator DSL for Scala
The Kompics Simulator DSL for Scala
case object SimpleSimulation { import Distributions._ // needed for the distributions, but needs to be initialised after setting the seed implicit val random = JSimulationScenario.getRandom(); private def intToAddress(i: Int): Address = { try { new TAddress(new InetSocketAddress(InetAddress.getByName("192.193.0." + i), 10000)); } catch { case ex: UnknownHostException => throw new RuntimeException(ex); } } val startResultSetterOp = Op { (self: Integer) => val selfAddr = intToAddress(self); StartNode(selfAddr, Init[ResultSetter](selfAddr)) }; val startPongerOp = Op { (self: Integer) => val selfAddr = intToAddress(self) StartNode(selfAddr, Init[PongerParent](selfAddr)) }; val startPingerOp = Op { (self: Integer, ponger: Integer) => val selfAddr = intToAddress(self); val pongerAddr = intToAddress(ponger); StartNode(selfAddr, Init[PingerParent](selfAddr, pongerAddr)) }; val scenario = raise(5, startPongerOp, 1.toN) .arrival(constant(1000.millis)) .andThen(1000.millis) .afterTermination(raise(5, startPingerOp, 6.toN, 1.toN).arrival(constant(1000.millis))) .inParallel(raise(1, startResultSetterOp, 1.toN).arrival(constant(1000.millis))) .andThen(10000.millis) .afterTermination(Terminate); }
Example:
Type Members
- trait AnyPort extends AnyRef
Methods for any kind of port no matter the direction
- case class ComponentAndPort[P <: PortType](posC: Component, neg: NegativePort[P]) extends Product with Serializable
A named tuple for a port and a component
A named tuple for a port and a component
- P
the port type shared by the port and the component
- abstract class ComponentDefinition extends kompics.ComponentDefinition
A Component Definition
- class Config extends AnyRef
A convenience DSL wrapper around se.sics.kompics.config.Config
- type Handler = PartialFunction[KompicsEvent, Unit]
The type returned by an
uponEvent
block. - case class Init[T <: ComponentDefinition](params: Any*) extends kompics.Init[T] with Product with Serializable
A convenient case class for matchable init events
A convenient case class for matchable init events
To assign values of the init instance to fields in a component use, for example:
val (field1: String, field2: Int) = init;
- T
the type of the component definition the init event is supposed to be used in
- params
all init arguments for the component
- type Kill = kompics.Kill
- See also
- type Killed = kompics.Killed
- See also
- type KompicsEvent = kompics.KompicsEvent
The supertype for any event.
The supertype for any event.
- See also
- trait NegativePort[P <: PortType] extends Negative[P] with AnyPort
Scala trait for a Negative port
- class NegativeWrapper[P <: PortType] extends NegativePort[P]
A wrapper for java ports to implement NegativePort
- abstract class Port extends PortType
The base class for a port type.
The base class for a port type.
To declare a new port type, extend this class in an object and then define the signature for the port, for example:
object TestPort extends Port { request[TestEventClass]; request(TestEventObject); indication[TestEventClass2]; indication(TestEventObject2); }
- case class PortAndComponent[P <: PortType](pos: PositivePort[P], negC: Component) extends Product with Serializable
A named tuple for a port and a component
A named tuple for a port and a component
- P
the port type shared by the port and the component
- case class PortAndPort[P <: PortType](pos: PositivePort[P], neg: NegativePort[P]) extends Product with Serializable
A named tuple for two ports in opposite directions
A named tuple for two ports in opposite directions
- P
the port type shared by both ports
- trait PositivePort[P <: PortType] extends Positive[P] with AnyPort
Scala trait for a Positive port
- class PositiveWrapper[P <: PortType] extends PositivePort[P]
A wrapper for java ports to implement PositivePort
- abstract class SConv[T] extends Converter[T]
A Scala converter variant of se.sics.kompics.config.Converter
A Scala converter variant of se.sics.kompics.config.Converter
- T
the target type of the converter
- class ScalaComponent extends ComponentCoreScala
The Scala implementation of se.sics.kompics.Component
The Scala implementation of se.sics.kompics.Component
- Attributes
- protected
- class ScalaComponentWrapper extends AnyRef
A wrapper to augment java component with Scala DSL
A wrapper to augment java component with Scala DSL
An implicit converion is available in the companion object.
- class ScalaPort[P <: PortType] extends PortCore[P] with NegativePort[P] with PositivePort[P]
A Scala implementation of the se.sics.kompics.PortCore
- type Start = kompics.Start
- See also
- type Started = kompics.Started
- See also
- type Stop = kompics.Stop
- See also
- type Stopped = kompics.Stopped
- See also
Value Members
- def !connect[P <: PortType](portType: P)(t: (Component, Component)): Channel[P]
Connect two components on a Scala port object
P
.Connect two components on a Scala port object
P
.- P
the type of the port to connect on
- portType
the instance object of the port type
- t
a tuple of two components which povide
P
in opposite directions- returns
the newly created channel
`!connect`(P)(c1 -> c2)
Example: - def !connect[P <: PortType](t: (Component, Component))(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[P]): Channel[P]
Connect two components on a Java port type
P
.Connect two components on a Java port type
P
.- P
the type of the port to connect on
- t
a tuple of two components which povide
P
in opposite directions- returns
the newly created channel
`!connect`[P](c1 -> c2)
Example: - def !connect[P <: PortType](t: ComponentAndPort[P]): Channel[P]
Connect a component
c
to a negative portp
of typeP
.Connect a component
c
to a negative portp
of typeP
.- P
the type of the port to connect on
- t
a tuple of a component and a port instance of type
P
- returns
the newly created channel
`!connect`[P](c -> p)
Example: - def !connect[P <: PortType](t: PortAndComponent[P]): Channel[P]
Connect a component
c
to a positive portp
of typeP
.Connect a component
c
to a positive portp
of typeP
.- P
the type of the port to connect on
- t
a tuple of a port instance of type
P
and a component- returns
the newly created channel
`!connect`[P](p -> c)
Example: - def !connect[P <: PortType](t: PortAndPort[P]): Channel[P]
Connect a positive port
p
to a negative portn
, both of typeP
.Connect a positive port
p
to a negative portn
, both of typeP
.- P
the type of the port to connect on
- t
two port instances of type
P
in opposite directions as a PortAndPort object- returns
the newly created channel
`!connect`[P](p -> n)
Example: - def !trigger[P <: PortType](t: (KompicsEvent, kompics.Port[P]))(implicit cd: kompics.ComponentDefinition): Unit
Trigger an event on a port via a component proxy.
Trigger an event on a port via a component proxy.
Must be used with a ComponentDefinition implicitly in context.
- P
the port type of the port to trigger on
- t
a tuple of a KompicsEvent and a port
`!trigger`(myEvent -> p)
Example: - val Kill: kompics.Kill
- See also
- val Start: kompics.Start
- See also
- val Stop: kompics.Stop
- See also
- def asJavaClass[T](te: scala.reflect.api.JavaUniverse.Type): Class[T]
Give the java class for a type
Give the java class for a type
- T
the target type
- te
the type instance
- returns
the java class for
T
- def handler(matcher: Handler): Handler
Conveniently create a Handler instance from a partial function of the right type
Conveniently create a Handler instance from a partial function of the right type
Does nothing really, and is only meant to enhance readability when handlers aren't subscribed immediately with uponEvent.
- matcher
the partial function that forms the handler's body
- returns
really just the partial function again
- implicit def option2optional[T](o: Option[T]): Optional[T]
- implicit def tuple2cnp[P <: PortType](t: (Component, NegativePort[P])): ComponentAndPort[P]
Automatically create a ComponentAndPort from port instance and a component
Automatically create a ComponentAndPort from port instance and a component
- P
the shared port type for both port and component
- returns
the new ComponentAndPort instance
- implicit def tuple2pnc[P <: PortType](t: (PositivePort[P], Component)): PortAndComponent[P]
Automatically create a PortAndComponent from port instance and a component
Automatically create a PortAndComponent from port instance and a component
- P
the shared port type for both port and component
- returns
the new PortAndComponent instance
- implicit def tuple2pnp[P <: PortType](t: (PositivePort[P], NegativePort[P])): PortAndPort[P]
Automatically create a PortAndPort from two port instances of opposite directions
Automatically create a PortAndPort from two port instances of opposite directions
- P
the shared port type for both port instances
- returns
the new PortAndPort instance
- object Config
- object Init extends Serializable
Provides access to variants of empty init events.
- object Kompics
Convenient object to forward static members of se.sics.kompics.Kompics.
- object NegativePort
Companion object providing utilities to create a NegativePort from a se.sics.kompics.PortCore
- object PositivePort
Companion object providing utilities to create a PositivePort from a se.sics.kompics.PortCore
- object PrimitiveConverters
A collection of converters for Scala primitives for use with the configuration utilities of Kompics
- object ScalaComponent extends Serializable
A companion with utilities.
- object ScalaPort
Companion utilities for the ScalaPort
Deprecated Value Members
- def handle(closure: => Unit): Unit
Does nothing in Kompics Scala 2.x.
Does nothing in Kompics Scala 2.x.
Simply remove it wherever encountered.
Only provided for source compatibility with legacy Kompics Scala 1.x code.
- Annotations
- @deprecated
- Deprecated
(Since version Kompics Scala 2.0.0) This is a no-op now and can safely be removed.