NAME
MCE::Subs - Exports funtions mapped directly to MCE's methods
VERSION
This document describes MCE::Subs version 1.499_003
SYNOPSIS
use MCE::Subs; ## Exports manager and worker functions only
## Getter functions are not exported by default
use MCE::Subs qw( :getter ); ## All, including getter functions
use MCE::Subs qw( :manager ); ## Exports manager functions only
use MCE::Subs qw( :worker ); ## Exports worker functions only
use MCE::Subs qw( :getter :worker ); ## Excludes manager functions
DESCRIPTION
This module exports functions mapped to MCE methods. All exported functions are prototyped, therefore allowing one to call them without using parentheses.
use MCE::Subs qw( :worker );
## barrier synchronization among workers
sub user_func {
my $wid = MCE->wid;
mce_say "A: $wid";
mce_sync;
mce_say "B: $wid";
mce_sync;
mce_say "C: $wid";
mce_sync;
return;
}
MCE->new(
max_workers => 24, user_func => \&user_func
);
mce_run 0 for (1..100); ## 0 means do not shutdown after running
For the next example, we only want the worker functions to be exported due to using MCE::Map, which takes care of creating a MCE instance and running.
use MCE::Map;
use MCE::Subs qw( :worker );
## The following will serialize output to STDOUT as well as gather
## to @a. mce_say displays $_ when called without arguments.
my @a = mce_map { mce_say; $_ } 1 .. 100;
print scalar @a, "\n";
Unlike the native Perl functions, print, printf, and say methods require the comma after the filehandle.
MCE->print("STDERR", $error_msg, "\n"); ## Requires quotes around
MCE->say("STDERR", $error_msg); ## the bareword FH.
MCE->say($fh, $error_msg);
mce_print STDERR, $error_msg, "\n"; ## Quotes can be ommitted
mce_say STDERR, $error_msg; ## around the bareword FH.
mce_say $fh, $error_msg;
FUNCTIONS for the MANAGER PROCESS via ( :manager )
- mce_abort
- mce_forchunk
- mce_foreach
- mce_forseq
- mce_freeze
- mce_process
- mce_restart_worker
- mce_run
- mce_print
- mce_printf
- mce_say
- mce_send
- mce_shutdown
- mce_spawn
- mce_status
- mce_thaw
FUNCTIONS for MCE WORKERS via ( :worker )
- mce_abort
- mce_do
- mce_exit
- mce_freeze
- mce_gather
- mce_last
- mce_next
- mce_print
- mce_printf
- mce_say
- mce_sendto
- mce_sync
- mce_thaw
- mce_yield
GETTERS for MCE ATTRIBUTES via ( :getter )
- mce_chunk_id
- mce_chunk_size
- mce_max_workers
- mce_sess_dir
- mce_task_id
- mce_task_name
- mce_task_wid
- mce_tmp_dir
- mce_user_args
- mce_wid
INDEX
AUTHOR
Mario E. Roy, <marioeroy AT gmail DOT com>
LICENSE
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.