class Timer extends AnyRef
supports the scheduling of delayed and periodic tasks.
Some example to illustrate the use of a timer:
val timer = new Timer(...) val myTask = timer.periodically(Time.second) { t => // do something every second timer.continueWhile(hasSomethingToDo) } val myOtherTask = timer.scheduleAfter(Time.second) { t => // do something one second later } timer.cancel(myOtherTask) // ... or not.
- Alphabetic
- By Inheritance
- Timer
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (Timer, B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
cancel(id: TaskID): Unit
Cancels a running task if it is found in the execution queue.
Cancels a running task if it is found in the execution queue.
- id
identifier of the task to cancel
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
final
def
continueUntil(cond: ⇒ Boolean): Boolean
The task is rescheduled if false.
The task is rescheduled if false. Syntactic sugar to clarify the last condition in periodic task.
- cond
the task is rescheduled if the condition is false
- Annotations
- @inline()
-
final
def
continueWhile(cond: ⇒ Boolean): Boolean
The task is rescheduled if true.
The task is rescheduled if true. Syntactic sugar to clarify the last condition in periodic task.
- cond
the task is rescheduled if the condition is true
- Annotations
- @inline()
- def ensuring(cond: (Timer) ⇒ Boolean, msg: ⇒ Any): Timer
- def ensuring(cond: (Timer) ⇒ Boolean): Timer
- def ensuring(cond: Boolean, msg: ⇒ Any): Timer
- def ensuring(cond: Boolean): Timer
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def formatted(fmtstr: String): String
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
isEmpty: Boolean
returns
true
if there are no more scheduled tasks.returns
true
if there are no more scheduled tasks.- returns
true
if there are no more scheduled tasks.
-
def
isEmptyBesideDaemons: Boolean
returns
true
if there are no more scheduled tasks, not counting daemon tasks.returns
true
if there are no more scheduled tasks, not counting daemon tasks.- returns
true
if there are no more scheduled tasks, not counting daemon tasks.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
nonEmpty: Boolean
returns
true
if there are still some scheduled tasks.returns
true
if there are still some scheduled tasks.- returns
true
if there are still some scheduled tasks.
-
def
nonEmptyBesideDaemons: Boolean
returns
true
if there are still some scheduled tasks, not counting daemon tasks.returns
true
if there are still some scheduled tasks, not counting daemon tasks.- returns
true
if there are still some scheduled tasks, not counting daemon tasks.
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
now: Time
Returns the current value of the clock elapsed since the beginning of the execution.
Returns the current value of the clock elapsed since the beginning of the execution. The value is in simulated time if the system runs as a simulation.
- returns
the current time
-
def
periodically(delay: Time, period: Time)(action: (Time) ⇒ Boolean): TaskID
Creates a new periodic task to periodically execute
action
, until it returnsfalse
.Creates a new periodic task to periodically execute
action
, until it returnsfalse
. To make the code more readable, one can use continueWhile or continueUntil as syntactic sugar.- delay
delay until the first execution of the task.
- period
interval between periodic executions of the task.
- action
the action to execute periodically. It is rescheduled if it returns
true
.- returns
identifier of the newly created task.
-
def
periodically(period: Time)(action: (Time) ⇒ Boolean): TaskID
Creates a new periodic task to periodically execute
action
, until it returnsfalse
.Creates a new periodic task to periodically execute
action
, until it returnsfalse
. Same as periodically(delay:neko\.util\.Time,period:neko\.util\.Time)(action:neko\.util\.Time=>Boolean):neko\.TaskID* but the first delay is the same as the period.(Time,Time)(Time⇒Boolean):TaskID*
- period
interval between periodic executions of the task, and delay until the first execution.
- action
the action to execute periodically. It is rescheduled if it returns
true
.- returns
identifier of the newly created task.
- def schedule(task: Task): TaskID
-
def
scheduleAfter(delay: Time)(action: (Time) ⇒ Unit): TaskID
Creates a new task which will be executed once, after the specified delay.
Creates a new task which will be executed once, after the specified delay. To make the code more readable, one can use continueWhile or continueUntil as syntactic sugar.
- delay
delay after which the task will be executed.
- action
the action to execute periodically. It is rescheduled if it returns
true
.- returns
identifier of the newly created task.
-
def
scheduleAt(time: Time)(action: (Time) ⇒ Unit): TaskID
Creates a new task which will be executed once, at a specified time (or immediately if already past).
Creates a new task which will be executed once, at a specified time (or immediately if already past). To make the code more readable, one can use continueWhile or continueUntil as syntactic sugar.
- time
time at which the task will be executed.
- action
the action to execute periodically. It is rescheduled if it returns
true
.- returns
identifier of the newly created task.
- val scheduler: Scheduler
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
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): (Timer, B)