The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sim::Clock - Simulation clock used by the dispatcher

VERSION

This document describes Sim::Clock 0.03 released on 2 June, 2007.

SYNOPSIS

    use Sim::Clock;
    my $clock = Sim::Clock->new(0);
    $clock->push_to(5.6);
    print $clock->now;  # 5.6
    $clock->push_to(3); # exception!
    $clock->reset();

DESCRIPTION

This class offers a simulation clock for Sim::Dispatcher. Basically you needn't create your own clock at all since Sim::Dispatcher always creates one internally and you seldom or never need more than one clock in your simulator. But you really feel the need to do something fancy, simulating quantum mechanics for example, here is the rope.

METHODS

$obj->new( $init_time ? )

Ths is the constructor for Sim::Clock objects. The $init_time argument specifies the initial time read of the clock and can be omitted.

$obj->now()

Reads the current time from the clock.

$obj->push_to($time)

Push the clock to the specified timestamp $time, which can't be earlier than the value obtained by the now method.

$obj->reset()

Resets the clock to time 0.

AUTHOR

Agent Zhang <agentzh@gmail.com>

COPYRIGHT

Copyright 2006 by Agent Zhang. All rights reserved.

This library is free software; you can modify and/or modify it under the same terms as Perl itself.

SEE ALSO

Sim::Dispatcher, Sim.