| 1 |
=head1 NAME |
| 2 |
|
| 3 |
Imager::Threads - Imager and threads |
| 4 |
|
| 5 |
=head1 SYNOPSIS |
| 6 |
|
| 7 |
use Imager; |
| 8 |
use threads; |
| 9 |
Imager->preload; |
| 10 |
|
| 11 |
threads->create(...); |
| 12 |
|
| 13 |
=head1 DESCRIPTION |
| 14 |
|
| 15 |
Starting from version 0.94 Imager attempts to work safely with perl's |
| 16 |
C<ithreads>. |
| 17 |
|
| 18 |
Previous versions stored some state in global variables, in particular |
| 19 |
the internal error stack. |
| 20 |
|
| 21 |
However there are some limitations: |
| 22 |
|
| 23 |
=over |
| 24 |
|
| 25 |
=item * |
| 26 |
|
| 27 |
Imager's debug malloc isn't thread safe and will never be. Imager's |
| 28 |
debug malloc is disabled by default. |
| 29 |
|
| 30 |
=item * |
| 31 |
|
| 32 |
C<libtiff>, which Imager uses for TIFF file support is not thread |
| 33 |
safe, C<Imager::File::TIFF> works around this by single-threading its |
| 34 |
access to C<libtiff>. |
| 35 |
|
| 36 |
=item * |
| 37 |
|
| 38 |
C<giflib>, which Imager uses for GIF support is not thread safe before |
| 39 |
version 5. C<Imager::File::GIF> works around this by single threading |
| 40 |
its access to C<giflib>. |
| 41 |
|
| 42 |
=item * |
| 43 |
|
| 44 |
C<T1Lib>, used by one of Imager's font drivers, is not thread safe. |
| 45 |
C<Imager::Font::T1> works around this by single threading access. |
| 46 |
|
| 47 |
=item * |
| 48 |
|
| 49 |
killing a thread reading or writing TIFF or GIF files, or using T1 |
| 50 |
fonts through C<Imager::Font::T1> may deadlock other threads when they |
| 51 |
attempt to read or write TIFF or GIF files, or work with Type 1 fonts. |
| 52 |
|
| 53 |
=item * |
| 54 |
|
| 55 |
Fill, font, color or I/O layer objects created in one thread are not |
| 56 |
valid for use in child threads. If you manage to duplicate such an |
| 57 |
object in another thread, you get to keep both pieces when it breaks. |
| 58 |
|
| 59 |
=back |
| 60 |
|
| 61 |
Note that if you have another module using C<libtiff>, C<giflib> or |
| 62 |
C<t1lib> it may interact with Imager's use of those libraries in a |
| 63 |
threaded environment, since there's no way to co-ordinate access to |
| 64 |
the global information C<libtiff>, C<giflib> and C<t1lib> maintain. |
| 65 |
|
| 66 |
Imager currently doesn't use threads itself, except for testing its |
| 67 |
threads support. |
| 68 |
|
| 69 |
=head1 SEE ALSO |
| 70 |
|
| 71 |
Imager, C<threads> |
| 72 |
|
| 73 |
=head1 AUTHOR |
| 74 |
|
| 75 |
Tony Cook <[email protected]> |
| 76 |
|
| 77 |
=cut |