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

NAME

Simulation::DiscreteEvent::Generator - Event generator

SYNOPSIS

    my $gen = $model->add(
        'Simulation::DiscreteEvent::Generator',
        start_at   => 2,
        interval   => sub { 7 * rand },
        message    => sub { sprintf "Now: %d", shift->model->time },
        event_name => 'ping',
        limit      => 1000,
        dest       => $server,
    );

DESCRIPTION

This class is descendant of Simulation::DiscreteEvent::Server, its purpose is to add event generators to model.

PARAMETERS

Here's the list of object attributes:

start_at

This attribute may be passed only at the time of object construction. It specifies the time of the first event. If you didn't specified this parameter you should schedule the "next" event for the created object, or it won't generate any events.

interval

This attribute is a reference to subroutine that returns time till the next event should happen. Usually this subroutine generates some random values. Reference to the object is passed to subroutine as the only argument. This attribute is required.

message

This optional attribute contains reference to a subroutine that generates messages which should be passed to destination event handler along with events.

event_name

Attribute contains name of the generated events.

limit

Number of events that should be generated. If attribute is not defined, generator will never stop while simulation is running.

dest

Server that should receive and handle generated events.

AUTHOR

Pavel Shaydo, <zwon at cpan.org>

SUPPORT

Please see documentation for Simulation::DiscreteEvent

LICENSE AND COPYRIGHT

Copyright 2010 Pavel Shaydo.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.