Blame IlmImf/ImfThreading.h

Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
//
Packit 0d464f
// Copyright (c) 2005, Industrial Light & Magic, a division of Lucas
Packit 0d464f
// Digital Ltd. LLC
Packit 0d464f
// 
Packit 0d464f
// All rights reserved.
Packit 0d464f
// 
Packit 0d464f
// Redistribution and use in source and binary forms, with or without
Packit 0d464f
// modification, are permitted provided that the following conditions are
Packit 0d464f
// met:
Packit 0d464f
// *       Redistributions of source code must retain the above copyright
Packit 0d464f
// notice, this list of conditions and the following disclaimer.
Packit 0d464f
// *       Redistributions in binary form must reproduce the above
Packit 0d464f
// copyright notice, this list of conditions and the following disclaimer
Packit 0d464f
// in the documentation and/or other materials provided with the
Packit 0d464f
// distribution.
Packit 0d464f
// *       Neither the name of Industrial Light & Magic nor the names of
Packit 0d464f
// its contributors may be used to endorse or promote products derived
Packit 0d464f
// from this software without specific prior written permission. 
Packit 0d464f
// 
Packit 0d464f
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 0d464f
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 0d464f
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 0d464f
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 0d464f
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 0d464f
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 0d464f
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 0d464f
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 0d464f
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 0d464f
//
Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
Packit 0d464f
#ifndef INCLUDED_IMF_THREADING_H
Packit 0d464f
#define INCLUDED_IMF_THREADING_H
Packit 0d464f
Packit 0d464f
#include "ImfExport.h"
Packit 0d464f
#include "ImfNamespace.h"
Packit 0d464f
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
//
Packit 0d464f
//	Threading support for the IlmImf library
Packit 0d464f
//
Packit 0d464f
//	The IlmImf library uses threads to perform reading and writing
Packit 0d464f
//	of OpenEXR files in parallel.  The thread that calls the library
Packit 0d464f
//	always performs the actual file IO (this is usually the main
Packit 0d464f
//	application thread) whereas a several worker threads perform
Packit 0d464f
//	data compression and decompression.  The number of worker
Packit 0d464f
//	threads can be any non-negative value (a value of zero reverts
Packit 0d464f
//	to single-threaded operation).  As long as there is at least
Packit 0d464f
//	one worker thread, file IO and compression can potentially be
Packit 0d464f
//	done concurrently through pinelining.  If there are two or more
Packit 0d464f
//	worker threads, then pipelining as well as concurrent compression
Packit 0d464f
//	of multiple blocks can be performed.
Packit 0d464f
// 
Packit 0d464f
//	Threading in the Imf library is controllable at two granularities:
Packit 0d464f
//
Packit 0d464f
//	* The functions in this file query and control the total number
Packit 0d464f
//	  of worker threads, which will be created globally for the whole
Packit 0d464f
//	  library.  Regardless of how many input or output files are
Packit 0d464f
//	  opened simultaneously, the library will use at most this number
Packit 0d464f
//	  of worker threads to perform all work.  The default number of
Packit 0d464f
//	  global worker threads is zero (i.e. single-threaded operation;
Packit 0d464f
//	  everything happens in the thread that calls the library).
Packit 0d464f
//
Packit 0d464f
//	* Furthermore, it is possible to set the number of threads that
Packit 0d464f
//	  each input or output file should keep busy.  This number can
Packit 0d464f
//	  be explicitly set for each file.  The default behavior is for
Packit 0d464f
//	  each file to try to occupy all worker threads in the library's
Packit 0d464f
//	  thread pool.
Packit 0d464f
//
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Packit 0d464f
Packit 0d464f
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
// Return the number of Imf-global worker threads used for parallel
Packit 0d464f
// compression and decompression of OpenEXR files.
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
    
Packit 0d464f
IMF_EXPORT int     globalThreadCount ();
Packit 0d464f
Packit 0d464f
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
// Change the number of Imf-global worker threads
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
Packit 0d464f
IMF_EXPORT void    setGlobalThreadCount (int count);
Packit 0d464f
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Packit 0d464f
Packit 0d464f
#endif