HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NullInterrupter.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 //
4 /// @file NullInterrupter.h
5 
6 #ifndef OPENVDB_UTIL_NULL_INTERRUPTER_HAS_BEEN_INCLUDED
7 #define OPENVDB_UTIL_NULL_INTERRUPTER_HAS_BEEN_INCLUDED
8 
9 #include <openvdb/version.h>
10 
11 namespace openvdb {
13 namespace OPENVDB_VERSION_NAME {
14 namespace util {
15 
16 /// @brief Dummy NOOP interrupter class defining interface
17 ///
18 /// This shows the required interface for the @c InterrupterType template argument
19 /// using by several threaded applications (e.g. tools/PointAdvect.h). The host
20 /// application calls start() at the beginning of an interruptible operation, end()
21 /// at the end of the operation, and wasInterrupted() periodically during the operation.
22 /// If any call to wasInterrupted() returns @c true, the operation will be aborted.
23 /// @note This Dummy interrupter will NEVER interrupt since wasInterrupted() always
24 /// returns false!
26 {
27  /// Default constructor
29  /// Signal the start of an interruptible operation.
30  /// @param name an optional descriptive name for the operation
31  void start(const char* name = nullptr) { (void)name; }
32  /// Signal the end of an interruptible operation.
33  void end() {}
34  /// Check if an interruptible operation should be aborted.
35  /// @param percent an optional (when >= 0) percentage indicating
36  /// the fraction of the operation that has been completed
37  /// @note this method is assumed to be thread-safe. The current
38  /// implementation is clearly a NOOP and should compile out during
39  /// optimization!
40  inline bool wasInterrupted(int percent = -1) { (void)percent; return false; }
41 };
42 
43 /// This method allows NullInterrupter::wasInterrupted to be compiled
44 /// out when client code only has a pointer (vs reference) to the interrupter.
45 ///
46 /// @note This is a free-standing function since C++ doesn't allow for
47 /// partial template specialization (in client code of the interrupter).
48 template <typename T>
49 inline bool wasInterrupted(T* i, int percent = -1) { return i && i->wasInterrupted(percent); }
50 
51 /// Specialization for NullInterrupter
52 template<>
53 inline bool wasInterrupted<util::NullInterrupter>(util::NullInterrupter*, int) { return false; }
54 
55 } // namespace util
56 } // namespace OPENVDB_VERSION_NAME
57 } // namespace openvdb
58 
59 #endif // OPENVDB_UTIL_NULL_INTERRUPTER_HAS_BEEN_INCLUDED
void
Definition: png.h:1083
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:178
GLuint const GLchar * name
Definition: glcorearb.h:785
Dummy NOOP interrupter class defining interface.
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
void end()
Signal the end of an interruptible operation.
Library and file format version numbers.
bool wasInterrupted(T *i, int percent=-1)
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:114