ImfThreading.h 2.6 KB

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