yum-archive/TaSTT-Whisper
High-performance GPGPU inference of OpenAI's Whisper automatic speech recognition (ASR) model
git clone https://git.yummers.dev/yum-archive/TaSTT-Whisper
8c4603c
master
1#pragma once 2#include <atomic> 3#include <assert.h> 4#include <limits.h> 5 6namespace ComLight 7{ 8// Very base class of objects, implements reference counting. 9class RefCounter 10 { 11 std::atomic_uint referenceCounter ; 12 13public : 14 15RefCounter () :referenceCounter (0 ) { } 16 17inline virtual ~RefCounter () { } 18 19RefCounter (const RefCounter & that )= delete ; 20RefCounter (RefCounter && that )= delete ; 21 22protected : 23 24uint32_t implAddRef () 25 { 26return ++ referenceCounter ; 27 } 28 29uint32_t implRelease () 30 { 31// Might be a good idea to use locks, at least in debug builds. They're much slower than atomics, but with locks it's possible to detect when 2 threads call release at the same time, for object with counter = 1. 32// It's a memory management bug, but it would be nice if debug builds would handle that case gracefully. 33const uint32_t rc = -- referenceCounter ; 34assert (rc != UINT_MAX ); 35return rc ; 36 } 37 }; 38}