… | |
… | |
40 | points in your program, so locking and parallel access are rarely an |
40 | points in your program, so locking and parallel access are rarely an |
41 | issue, making thread programming much safer and easier than using other |
41 | issue, making thread programming much safer and easier than using other |
42 | thread models. |
42 | thread models. |
43 | |
43 | |
44 | Unlike the so-called "Perl threads" (which are not actually real threads |
44 | Unlike the so-called "Perl threads" (which are not actually real threads |
45 | but only the windows process emulation ported to unix), Coro provides a |
45 | but only the windows process emulation ported to unix, and as such act |
46 | full shared address space, which makes communication between threads |
46 | as processes), Coro provides a full shared address space, which makes |
47 | very easy. And threads are fast, too: disabling the Windows process |
47 | communication between threads very easy. And Coro's threads are fast, |
48 | emulation code in your perl and using Coro can easily result in a two to |
48 | too: disabling the Windows process emulation code in your perl and using |
49 | four times speed increase for your programs. |
49 | Coro can easily result in a two to four times speed increase for your |
|
|
50 | programs. A parallel matrix multiplication benchmark runs over 300 times |
|
|
51 | faster on a single core than perl's pseudo-threads on a quad core using |
|
|
52 | all four cores. |
50 | |
53 | |
51 | Coro achieves that by supporting multiple running interpreters that share |
54 | Coro achieves that by supporting multiple running interpreters that share |
52 | data, which is especially useful to code pseudo-parallel processes and |
55 | data, which is especially useful to code pseudo-parallel processes and |
53 | for event-based programming, such as multiple HTTP-GET requests running |
56 | for event-based programming, such as multiple HTTP-GET requests running |
54 | concurrently. See L<Coro::AnyEvent> to learn more on how to integrate Coro |
57 | concurrently. See L<Coro::AnyEvent> to learn more on how to integrate Coro |
55 | into an event-based environment. |
58 | into an event-based environment. |
56 | |
59 | |
57 | In this module, a thread is defined as "callchain + lexical variables + |
60 | In this module, a thread is defined as "callchain + lexical variables + |
58 | @_ + $_ + $@ + $/ + C stack), that is, a thread has its own callchain, |
61 | some package variables + C stack), that is, a thread has its own callchain, |
59 | its own set of lexicals and its own set of perls most important global |
62 | its own set of lexicals and its own set of perls most important global |
60 | variables (see L<Coro::State> for more configuration and background info). |
63 | variables (see L<Coro::State> for more configuration and background info). |
61 | |
64 | |
62 | See also the C<SEE ALSO> section at the end of this document - the Coro |
65 | See also the C<SEE ALSO> section at the end of this document - the Coro |
63 | module family is quite large. |
66 | module family is quite large. |