README 1.8 KB

123456789101112131415161718192021222324252627282930313233
  1. This module collection manages continuations in general, most often in
  2. the form of cooperative threads (also called coros, or simply "coro" in
  3. the documentation). They are similar to kernel threads but don't (in
  4. general) run in parallel at the same time even on SMP machines. The
  5. specific flavor of thread offered by this module also guarantees you
  6. that it will not switch between threads unless necessary, at
  7. easily-identified points in your program, so locking and parallel access
  8. are rarely an issue, making thread programming much safer and easier
  9. than using other thread models.
  10. Unlike the so-called "Perl threads" (which are not actually real threads
  11. but only the windows process emulation (see section of same name for
  12. more details) ported to UNIX, and as such act as processes), Coro
  13. provides a full shared address space, which makes communication between
  14. threads very easy. And coro threads are fast, too: disabling the Windows
  15. process emulation code in your perl and using Coro can easily result in
  16. a two to four times speed increase for your programs. A parallel matrix
  17. multiplication benchmark (very communication-intensive) runs over 300
  18. times faster on a single core than perls pseudo-threads on a quad core
  19. using all four cores.
  20. Coro achieves that by supporting multiple running interpreters that
  21. share data, which is especially useful to code pseudo-parallel processes
  22. and for event-based programming, such as multiple HTTP-GET requests
  23. running concurrently. See Coro::AnyEvent to learn more on how to
  24. integrate Coro into an event-based environment.
  25. In this module, a thread is defined as "callchain + lexical variables +
  26. some package variables + C stack), that is, a thread has its own
  27. callchain, its own set of lexicals and its own set of perls most
  28. important global variables (see Coro::State for more configuration and
  29. background info).