| 63 | template <typename MapT> struct RegisterMap { inline void operator()() { MapT::registerMap(); } }; |
| 64 | |
| 65 | void |
| 66 | initialize() |
| 67 | { |
| 68 | if (sIsInitialized.load(std::memory_order_acquire)) return; |
| 69 | std::lock_guard<std::mutex> lock(GetInitMutex()); |
| 70 | if (sIsInitialized.load(std::memory_order_acquire)) return; // Double-checked lock |
| 71 | |
| 72 | logging::initialize(); |
| 73 | |
| 74 | // Register metadata. |
| 75 | Metadata::clearRegistry(); |
| 76 | MetaTypes::foreach<RegisterMeta>(); |
| 77 | |
| 78 | // Register maps |
| 79 | math::MapRegistry::clear(); |
| 80 | MapTypes::foreach<RegisterMap>(); |
| 81 | |
| 82 | // Register common grid types. |
| 83 | GridBase::clearRegistry(); |
| 84 | GridTypes::foreach<RegisterGrid>(); |
| 85 | |
| 86 | // Register types associated with point index grids. |
| 87 | Metadata::registerType(typeNameAsString<PointIndex32>(), Int32Metadata::createMetadata); |
| 88 | Metadata::registerType(typeNameAsString<PointIndex64>(), Int64Metadata::createMetadata); |
| 89 | |
| 90 | // Register types associated with point data grids. |
| 91 | points::internal::initialize(); |
| 92 | |
| 93 | #ifdef OPENVDB_USE_BLOSC |
| 94 | blosc_init(); |
| 95 | if (blosc_set_compressor("lz4") < 0) { |
| 96 | OPENVDB_LOG_WARN("Blosc LZ4 compressor is unavailable"); |
| 97 | } |
| 98 | /// @todo blosc_set_nthreads(int nthreads); |
| 99 | #endif |
| 100 | |
| 101 | #ifdef __ICC |
| 102 | // Disable ICC "assignment to statically allocated variable" warning. |
| 103 | // This assignment is mutex-protected and therefore thread-safe. |
| 104 | __pragma(warning(disable:1711)) |
| 105 | #endif |
| 106 | |
| 107 | sIsInitialized.store(true, std::memory_order_release); |
| 108 | |
| 109 | #ifdef __ICC |
| 110 | __pragma(warning(default:1711)) |
| 111 | #endif |
| 112 | } |
| 113 | |
| 114 | |
| 115 | void |