MCPcopy Create free account
hub / github.com/RenderKit/oidn / SemaphoreRef

Class SemaphoreRef

include/OpenImageDenoise/oidn.hpp:360–434  ·  view source on GitHub ↗

Semaphore object with automatic reference counting

Source from the content-addressed store, hash-verified

358
359 // Semaphore object with automatic reference counting
360 class SemaphoreRef
361 {
362 public:
363 SemaphoreRef() : handle(nullptr) {}
364 SemaphoreRef(OIDNSemaphore handle) : handle(handle) {}
365
366 SemaphoreRef(const SemaphoreRef& other) : handle(other.handle)
367 {
368 if (handle)
369 oidnRetainSemaphore(handle);
370 }
371
372 SemaphoreRef(SemaphoreRef&& other) noexcept : handle(other.handle)
373 {
374 other.handle = nullptr;
375 }
376
377 SemaphoreRef& operator =(const SemaphoreRef& other)
378 {
379 if (&other != this)
380 {
381 if (other.handle)
382 oidnRetainSemaphore(other.handle);
383 if (handle)
384 oidnReleaseSemaphore(handle);
385 handle = other.handle;
386 }
387 return *this;
388 }
389
390 SemaphoreRef& operator =(SemaphoreRef&& other) noexcept
391 {
392 std::swap(handle, other.handle);
393 return *this;
394 }
395
396 SemaphoreRef& operator =(OIDNSemaphore other)
397 {
398 if (other)
399 oidnRetainSemaphore(other);
400 if (handle)
401 oidnReleaseSemaphore(handle);
402 handle = other;
403 return *this;
404 }
405
406 ~SemaphoreRef()
407 {
408 if (handle)
409 oidnReleaseSemaphore(handle);
410 }
411
412 const OIDNSemaphore& getHandle() const
413 {
414 return handle;
415 }
416
417 operator bool() const

Callers

nothing calls this directly

Calls 2

oidnRetainSemaphoreFunction · 0.85
oidnReleaseSemaphoreFunction · 0.85

Tested by

no test coverage detected