Struct j2ds::Clock [−][src]
pub struct Clock { /* fields omitted */ }
An increasing counter that ticks up until a particular count is reached, which then resets itself
Example:
use j2ds::*; fn periodically_called_function(clock: &mut Clock) { // Do some stuff... if clock.tick() { // Do something special... } }
Methods
impl Clock
[src]
impl Clock
pub fn new(period: u64) -> Clock
[src]
pub fn new(period: u64) -> Clock
Create a new clock that cycles every period
ticks
pub fn tick(&mut self) -> bool
[src]
pub fn tick(&mut self) -> bool
Increment the current count by 1. If this is the period
-th
tick, the counter is reset and true
is returned.
pub fn reset(&mut self)
[src]
pub fn reset(&mut self)
Reset the current count
pub fn count(&self) -> u64
[src]
pub fn count(&self) -> u64
Return the current count
pub fn period(&self) -> u64
[src]
pub fn period(&self) -> u64
Return the period of the clock
Trait Implementations
impl Debug for Clock
[src]
impl Debug for Clock
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Eq for Clock
[src]
impl Eq for Clock
impl PartialEq for Clock
[src]
impl PartialEq for Clock