TaskResource

class TaskResource(val name: String, val costPerTick: Double)

A persistent resource to be used by Tasks/TaskInstances.

A TaskResource, or simply "resource", corresponds to a persistent resource. Typical examples are human actors or persistent machinery.

Each Task may require a different combination of resources.

Each TaskResource is assumed to have a unique name and a costPerTick, i.e. the cost (if any) of using the resource per unit of time.

We say a TaskResource is ''attached'' to a TaskInstance when the task that uses this resource is being performed. The currentTask variable holds the task that is currently attached to the resource (if any) coupled with the virtual timestamp of when it started. A TaskResource is ''idle''' when it has no tasks attached to it.

The Coordinator calls upon startTask to attach a task to the resource and finishTask to detach it. The Coordinator has full control over the resource and makes all necessary checks to ensure consistent behaviour (e.g. not starting a TaskInstance when another TaskInstance is already attached).

Value Params
costPerTick

The cost of using the resource per unit of time.

name

The name of the resource.

class Object
trait Matchable
class Any

Value members

Concrete methods

def abortSimulation(simulation: String): Option[(Long, TaskInstance)]

Aborts the current TaskInstance if it belongs to the given simulation.

Aborts the current TaskInstance if it belongs to the given simulation.

Does not do anything to the task itself. It merely detaches it and becomes idle.

Value Params
simulation

The name of the simulation whose tasks to abort.

Returns

The starting time and TaskInstance if it was aborted successfully or None in any other case.

def abortTask(id: UUID): Option[(Long, TaskInstance)]

Aborts the current TaskInstance if it matches a given UUID.

Aborts the current TaskInstance if it matches a given UUID.

Does not do anything to the task itself. It merely detaches it and becomes idle.

Value Params
id

The UUID of the TaskInstance to abort.

Returns

The starting time and TaskInstance if it was aborted successfully or None in any other case.

def finishTask(currentTime: Long): Option[TaskInstance]

Detaches the current TaskInstance (if any) if it has completed.

Detaches the current TaskInstance (if any) if it has completed.

Checks to ensure the task is completed with respect to the current time and the task duration.

Does not do anything to the task itself. It merely detaches it and becomes idle.

Value Params
currentTime

The current (virtual) time.

Returns

The TaskInstance that was detached, if any.

def isIdle: Boolean

True if the resource is idle, false otherwise.

True if the resource is idle, false otherwise.

Returns

true if the resource is idle, false otherwise.

def nextAvailableTimestamp(currentTime: Long): Long

Estimates the earliest time the resource will become available.

Estimates the earliest time the resource will become available.

Lets the Scheduler (via TaskInstance.nextPossibleStart) know an '''estimate''' of when we expect to have this resource available again.

This is based off of TaskInstance.estimatedDuration so may not be the accurate, but is more realistic in terms of what we know at a specific given point in time.

Returns

the estimated earliest time the resource will become available

def startTask(task: TaskInstance, currentTime: Long): Option[TaskInstance]

Attach a TaskInstance to this resource.

Attach a TaskInstance to this resource.

If the resource is already attached to another TaskInstance, the attached task is returned. Otherwise, we return scala.None.

Value Params
currentTime

The current (virtual) time.

task

The TaskInstance to attach.

Returns

None if the task was attached, or some TaskInstance that was already attached before

Concrete fields

val costPerTick: Double
var currentTask: Option[(Long, TaskInstance)]

Some TaskInstance currently attached to the resource, or scala.None if idle.

Some TaskInstance currently attached to the resource, or scala.None if idle.

val name: String