NAME

POEx::WorkerPool::Role::WorkerPool - A role that provides common semantics for WorkerPools

VERSION

version 1.101040

PUBLIC_ATTRIBUTES

job_classes

is: ro, isa: ArrayRef[ClassName], required: 1

In order for the serializer on the other side of the process boundary to rebless jobs on the other side, it needs to make sure that the classes are loaded.

This attribute is used to indicate which classes need to be loaded.

options

is: ro, isa: HashRef

options is the same options that would be passed to Sessions. Setting trace to 1 will allow tracing for the Workers.

POEx::WorkerPool->new(options => { trace => 1 });

queue_type

is: ro, isa: enum([qw|round_robin fill_up|]), default: round_robin

This attribute specifies the queue type for the WorkerPool and changes how workers are pulled from the pool

max_workers

is: ro, isa: Int, default: 5

This determines how many workers the Pool will spin up

current_worker_index

is: rw, isa: ScalarRef

This stores the current index into workers. Dereference to manipulate the Int value.

workers

is: ro, isa: ArrayRef[Worker]

This attribute holds all of the workers in the pool

max_jobs_per_worker

is: ro, isa: Int, default: 5

This attribute let's the workers know how many jobs their queue can hold

PUBLIC_METHODS

incr_worker_index

returns Int

This is a convenience method for incrementing the index and wrapping around when it exceeds max_workers

get_next_worker

returns (DoesWorker)

This returns the next worker in the pool as determined by the queue_type attribute.

For round_robin, it will return the next immediate worker if isn't active. fill_up will continue to return the same worker until its job queue is full.

If it is unable to return a suitable worker (all of the workers are currently active or all of their job queues are full, etc), it will throw a POEx::WorkerPool::Error::NoAvailableWorkers exception.

queue_job

(DoesJob $job) returns (SessionAlias)

This method grabs the next available worker, enqueues the job, starts the worker's queue processing and returns the worker's pubsub alias that can be used to subscribe to various events that the worker fires.

halt

This method will halt any active workers in the worker pool and force them to release resouces and clean up.

AUTHOR

Nicholas Perez <nperez@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Infinity Interactive.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.