package kernel
- Alphabetic
- Public
- All
Type Members
-
case class
ActivityID(value: Int) extends ID[Int] with Product with Serializable
identifier of an activity.
identifier of an activity. Activities are represented by the trait ManagedActivity.
- value
unique number identifying the activity
- Attributes
- protected[neko]
-
class
ActivityManager extends Mutable with LazyLogging
handles the lockstep execution of registered concurrent activities (protocol objects that implement the trait ManagedActivity).
handles the lockstep execution of registered concurrent activities (protocol objects that implement the trait ManagedActivity).
The activities are assumed to exchange information using a producer-consumer model such as java.util.concurrent.BlockingQueue. The model is not safe if the activity is actually be made to wait on the queue (see details at the bottom).
Initialization:
- new activities are registered by calling registerActivity, which provides an identifier (ActivityID).
- after all activities have been registered, the activity manager is started start.
- the activities are started just like normal threads.
The lifecycle of an activity is as follows:
- upon starting, the activity first calls willStart once, and starts its concurrent execution as a thread.
- Each time the activity would be required to wait on a queue (checked by polling on the structure), it will instead wait through a call to willWait, and proceed to do the blocking call only once it is sure that it will not be made to wait.
- Once the activity has finished its normal execution, it calls willFinish which blocks until all other threads have finished.
After all activities started, the lockstep execution proceeds as follows:
- all activities execute concurrently until all of them are blocked on a call to willWait or willFinish.
- the manager executes all registered actions (i.e., actions registered through registerAction) sequentially, and in mutual exclusion with the activities.
- after all actions have been executed once, the cycle repeats if some activity has called willWait, or the cycle ends if all activities have called willFinish.
Additional notes on synchronization
As said before, activities can't be made to actually wait on a queue. This means that the queue must provide a means for polling (such as java.util.concurrent.BlockingQueue!.isEmpty), to make sure that the thread will not actually be blocked by the queue. Practically speaking, this means that:
- some scala synchronization primitives like scala.concurrent.SyncVar or scala.concurrent.SyncChannel can't be used safely.
- the queue can have only one consumer.
- the queue must either be unbounded (e.g., java.util.concurrent.LinkedBlockingQueue as used in the implementation of neko.ActiveProtocol) or it must have a reserved location for every producer activity.
- Attributes
- protected[neko]
- trait Dispatcher extends Receiver
-
trait
ManagedActivity extends AnyRef
Trait that should be mixed in with any protocol having its own thread of execution (i.e., an instance of java.lang.Runnable).
Trait that should be mixed in with any protocol having its own thread of execution (i.e., an instance of java.lang.Runnable). It is unlikely that an application programmer will ever have to use this trait directly, but will instead extend ActiveProtocol for the top-level active part of the protocol stack, or rely on Timer with a reactive protocol to generate events spontaneously.
- abstract class NekoSystem extends LazyLogging
- class ParallelScheduler extends Scheduler
- case class PeriodicTask(scheduler: Scheduler, time: Time, period: Time, repeatAction: (Time) ⇒ Boolean, id: TaskID = TaskID.autoIncrement()) extends Task with Product with Serializable
- abstract class Scheduler extends LazyLogging
- class SequentialScheduler extends Scheduler
- class SimpleDispatcher extends Dispatcher
- case class SimpleTask(time: Time, action: (Time) ⇒ Unit, id: TaskID = TaskID.autoIncrement()) extends Task with Product with Serializable
- sealed abstract class Task extends Ordered[Task]
Value Members
-
object
ActivityManager
- Attributes
- protected[neko]
- object Dispatcher
- object Initializer
- object NekoSystem
- object Scheduler
- object Task