godot_voxel/util/ref_count.h
Marc Gilleron e9af708c3b Moved some utility functions
- sort goes to math funcs
- math funcs specializations for vector types go to vector files
- use ZN macros in a few more places
2022-04-14 21:22:22 +01:00

32 lines
515 B
C++

#ifndef VOXEL_VIEWER_REF_COUNT_H
#define VOXEL_VIEWER_REF_COUNT_H
#include "errors.h"
namespace zylann {
// Simple reference counter.
// This one is not thread-safe.
class RefCount {
public:
inline void add() {
++_count;
}
inline void remove() {
ZN_ASSERT_RETURN_MSG(_count != 0, "Trying to decrease refcount when it's already zero");
--_count;
}
inline unsigned int get() const {
return _count;
}
private:
unsigned int _count = 0;
};
} // namespace zylann
#endif // VOXEL_VIEWER_REF_COUNT_H