| 1 | // |
| 2 | // SPDX-License-Identifier: BSD-3-Clause |
| 3 | // Copyright (c) Contributors to the OpenEXR Project. |
| 4 | // |
| 5 | |
| 6 | #ifndef INCLUDED_IMF_THREADING_H |
| 7 | #define INCLUDED_IMF_THREADING_H |
| 8 | |
| 9 | #include "ImfExport.h" |
| 10 | #include "ImfNamespace.h" |
| 11 | |
| 12 | //----------------------------------------------------------------------------- |
| 13 | // |
| 14 | // Threading support for the OpenEXR library |
| 15 | // |
| 16 | // The OpenEXR library uses threads to perform reading and writing |
| 17 | // of OpenEXR files in parallel. The thread that calls the library |
| 18 | // always performs the actual file IO (this is usually the main |
| 19 | // application thread) whereas a several worker threads perform |
| 20 | // data compression and decompression. The number of worker |
| 21 | // threads can be any non-negative value (a value of zero reverts |
| 22 | // to single-threaded operation). As long as there is at least |
| 23 | // one worker thread, file IO and compression can potentially be |
| 24 | // done concurrently through pinelining. If there are two or more |
| 25 | // worker threads, then pipelining as well as concurrent compression |
| 26 | // of multiple blocks can be performed. |
| 27 | // |
| 28 | // Threading in the EXR library is controllable at two granularities: |
| 29 | // |
| 30 | // * The functions in this file query and control the total number |
| 31 | // of worker threads, which will be created globally for the whole |
| 32 | // library. Regardless of how many input or output files are |
| 33 | // opened simultaneously, the library will use at most this number |
| 34 | // of worker threads to perform all work. The default number of |
| 35 | // global worker threads is zero (i.e. single-threaded operation; |
| 36 | // everything happens in the thread that calls the library). |
| 37 | // |
| 38 | // * Furthermore, it is possible to set the number of threads that |
| 39 | // each input or output file should keep busy. This number can |
| 40 | // be explicitly set for each file. The default behavior is for |
| 41 | // each file to try to occupy all worker threads in the library's |
| 42 | // thread pool. |
| 43 | // |
| 44 | //----------------------------------------------------------------------------- |
| 45 | |
| 46 | OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
| 47 | |
| 48 | |
| 49 | //----------------------------------------------------------------------------- |
| 50 | // Return the number of Imf-global worker threads used for parallel |
| 51 | // compression and decompression of OpenEXR files. |
| 52 | //----------------------------------------------------------------------------- |
| 53 | |
| 54 | IMF_EXPORT int globalThreadCount (); |
| 55 | |
| 56 | |
| 57 | //----------------------------------------------------------------------------- |
| 58 | // Change the number of Imf-global worker threads |
| 59 | //----------------------------------------------------------------------------- |
| 60 | |
| 61 | IMF_EXPORT void setGlobalThreadCount (int count); |
| 62 | |
| 63 | |
| 64 | OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
| 65 | |
| 66 | #endif |
| 67 | |