MCPcopy Create free account
hub / github.com/apache/tvm-ffi / InitWithCounter

Function InitWithCounter

tests/cpp/test_init_once.cc:166–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164static std::atomic<int>* g_deinit_count = nullptr;
165
166static int InitWithCounter(void** handle_addr) {
167 auto* counter = new ThreadSafeCounter(42, g_init_count, g_deinit_count);
168 if (counter->init_count_ptr) {
169 counter->init_count_ptr->fetch_add(1, std::memory_order_relaxed);
170 }
171 // Small delay to increase the race window
172 std::this_thread::sleep_for(std::chrono::microseconds(100));
173 *handle_addr = counter;
174 return 0;
175}
176
177static int DeinitWithCounter(void* h) {
178 auto* counter = static_cast<ThreadSafeCounter*>(h);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected