22.03.2015 Views

DLI Implementation and Reference Guide - Datalogics

DLI Implementation and Reference Guide - Datalogics

DLI Implementation and Reference Guide - Datalogics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.14 <strong>DLI</strong> <strong>Implementation</strong> <strong>and</strong> <strong>Reference</strong> <strong>Guide</strong><br />

example, the following sequence will cause errors when attempting to initialize<br />

Thread 2:<br />

Concepts <strong>and</strong> dlpdfinit() Facilities: <strong>Guide</strong> to the DL Pager Composition System<br />

[Thread 1 processing]<br />

dlpdfterm()<br />

dlpdfinit()<br />

[Thread 2 processing]<br />

dlpdfterm()<br />

The problem above is that when Thread 1 terminates, no other processes are seen, <strong>and</strong><br />

so shutdown cleanup work begins, leading to errors when the initialization of Thread<br />

2 comes along.<br />

This sequence is recommended instead:<br />

dlpdfinit()<br />

dlpdfinit()<br />

[thread 1 processing]<br />

[thread 2 processing]<br />

dlpdfterm()<br />

dlpdfterm()<br />

Thread-Safe Issues<br />

Releases of the Adobe PDF Library prior to v6.1 are not thread-safe, <strong>and</strong> so by<br />

extension neither is <strong>DLI</strong>. Adobe PDF Library v6.1 <strong>and</strong> its accompanying <strong>DLI</strong> is the<br />

first thread-safe release in distribution. Notes on use of prior versions within multithreaded<br />

applications are given below. It is possible to use pre-v6.1, non-thread-safe<br />

Library applications in a threaded environment under the proper configuration in<br />

certain circumstances (although you should plan to upgrade your application to a<br />

thread-safe Adobe PDF Library v6.1.x version at your next opportunity).<br />

The general idea is that your application will queue the threads' interaction with the<br />

Library functions so that they are executed one at a time. This is not too difficult to do<br />

if your pre-v6.1.x application uses a mutex (Mutual Exclusion) algorithm to ensure<br />

that only one thread has access to the Library at any given point in time. Testing has<br />

shown that execution time does not appear negatively impacted if the Library<br />

segments are efficiently grouped, so that any given thread's Library activity is over<br />

<strong>and</strong> done with before the next process calls. When properly implemented, there

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!