1Mojo::IOLoop::ReadWriteUPsreorceCsosn:t:rPioboult(e3d)PMeorjlo:D:oIcOuLmoeonpt:a:tRieoandWriteProcess::Pool(3)
2
3
4

NAME

6       Mojo::IOLoop::ReadWriteProcess::Pool - Pool of
7       Mojo::IOLoop::ReadWriteProcess objects.
8

SYNOPSIS

10           use Mojo::IOLoop::ReadWriteProcess qw(parallel);
11           my $n_proc = 20;
12           my $fired;
13
14           my $p = parallel sub { print "Hello world\n"; } => $n_proc;
15
16           # Subscribe to all "stop" events in the pool
17           $p->once(stop => sub { $fired++; });
18
19           # Start all processes belonging to the pool
20           $p->start();
21
22           # Receive the process output
23           $p->each(sub { my $p = shift; $p->getline(); });
24           $p->wait_stop;
25
26           # Get the last one! (it's a Mojo::Collection!)
27           $p->last()->stop();
28

METHODS

30       Mojo::IOLoop::ReadWriteProcess::Pool inherits all methods from
31       Mojo::Collection and implements the following new ones.  Note: It
32       proxies all the other methods of Mojo::IOLoop::ReadWriteProcess for the
33       whole process group.
34
35   get
36           use Mojo::IOLoop::ReadWriteProcess qw(parallel);
37           my $pool = parallel(sub { print "Hello" } => 5);
38           $pool->get(4);
39
40       Get the element specified in the pool (starting from 0).
41
42   add
43           use Mojo::IOLoop::ReadWriteProcess qw(pool);
44           my $pool = pool(maximum_processes => 2);
45           $pool->add(sub { print "Hello 2! " });
46
47       Add the element specified in the pool.
48
49   remove
50           use Mojo::IOLoop::ReadWriteProcess qw(parallel);
51           my $pool = parallel(sub { print "Hello" } => 5);
52           $pool->remove(4);
53
54       Remove the element specified in the pool.
55
56   maximum_processes
57           use Mojo::IOLoop::ReadWriteProcess qw(parallel);
58           my $pool = parallel(sub { print "Hello" } => 5);
59           $pool->maximum_processes(30);
60           $pool->add(...);
61
62       Prevent from adding processes to the pool. If we reach
63       "maximum_processes" number of processes, "add()" will refuse to add
64       more to the pool.
65

ENVIRONMENT

67       You can set the MOJO_PROCESS_MAXIMUM_PROCESSES environment variable to
68       specify the the maximum number of processes allowed in
69       Mojo::IOLoop::ReadWriteProcess instances.
70
71           MOJO_PROCESS_MAXIMUM_PROCESSES=10000
72

LICENSE

74       Copyright (C) Ettore Di Giacinto.
75
76       This library is free software; you can redistribute it and/or modify it
77       under the same terms as Perl itself.
78

AUTHOR

80       Ettore Di Giacinto <edigiacinto@suse.com>
81
82
83
84perl v5.30.1                      2020-0M1o-j3o0::IOLoop::ReadWriteProcess::Pool(3)
Impressum