---
name: "MCE::Subs"
section: "3pm"
platform: "linux"
package: "libmce-perl"
version: "1.901-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/MCE::Subs"
---

# MCE::Subs(3pm)

Exports functions mapped directly to MCE methods

## NAME

MCE::Subs - Exports functions mapped directly to MCE methods

## VERSION

This document describes MCE::Subs version 1.901

## 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 );
 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 serializes output to STDOUT and gathers $_ 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, printf, print, and say methods require the comma after the glob reference or file handle.

```
 MCE->printf(\*STDERR, "%s\n", $error_msg);
 MCE->print(\*STDERR, $error_msg, "\n");
 MCE->say(\*STDERR, $error_msg);
 MCE->say($fh, $error_msg);
 mce_printf \*STDERR, "%s\n", $error_msg;
 mce_print \*STDERR, $error_msg, "\n";
 mce_say \*STDERR, $error_msg;
 mce_say $fh, $error_msg;
```

## FUNCTIONS for the MANAGER PROCESS via ( :manager )

MCE methods are described in MCE::Core.

- •

  mce\_abort

- •

  mce\_do

- •

  mce\_forchunk

- •

  mce\_foreach

- •

  mce\_forseq

- •

  mce\_freeze

- •

  mce\_process

- •

  mce\_relay\_final

- •

  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 methods are described in MCE::Core.

- •

  mce\_abort

- •

  mce\_do

- •

  mce\_exit

- •

  mce\_freeze

- •

  mce\_gather

- •

  mce\_last

- •

  mce\_next

- •

  mce\_print

- •

  mce\_printf

- •

  mce\_relay

- •

  mce\_relay\_recv

- •

  mce\_say

- •

  mce\_sendto

- •

  mce\_sync

- •

  mce\_thaw

- •

  mce\_yield

## GETTERS for MCE ATTRIBUTES via ( :getter )

MCE methods are described in MCE::Core.

- •

  mce\_chunk\_id

- •

  mce\_chunk\_size

- •

  mce\_max\_retries

- •

  mce\_max\_workers

- •

  mce\_pid

- •

  mce\_seed

- •

  mce\_sess\_dir

- •

  mce\_task\_id

- •

  mce\_task\_name

- •

  mce\_task\_wid

- •

  mce\_tmp\_dir

- •

  mce\_user\_args

- •

  mce\_wid

## INDEX

MCE, MCE::Core

## AUTHOR

Mario E. Roy, \<marioeroy AT gmail DOT com\>
