#include <object_cache.h>
template<typename T>
class tesseract::ObjectCache< T >
Definition at line 35 of file object_cache.h.
◆ ObjectCache()
◆ ~ObjectCache()
Definition at line 38 of file object_cache.h.
39 std::lock_guard<std::mutex> guard(mu_);
40 for (
int i = 0; i < cache_.
size(); i++) {
41 if (cache_[i].
count > 0) {
42 tprintf(
"ObjectCache(%p)::~ObjectCache(): WARNING! LEAK! object %p "
43 "still has count %d (id %s)\n",
44 this, cache_[i].
object, cache_[i].
count,
45 cache_[i].
id.c_str());
47 delete cache_[i].object;
48 cache_[i].object =
nullptr;
◆ DeleteUnusedObjects()
Definition at line 93 of file object_cache.h.
94 std::lock_guard<std::mutex> guard(mu_);
95 for (
int i = cache_.
size() - 1; i >= 0; i--) {
96 if (cache_[i].
count <= 0) {
97 delete cache_[i].object;
◆ Free()
Definition at line 81 of file object_cache.h.
82 if (t ==
nullptr)
return false;
83 std::lock_guard<std::mutex> guard(mu_);
84 for (
int i = 0; i < cache_.
size(); i++) {
85 if (cache_[i].
object == t) {
◆ Get()
Definition at line 59 of file object_cache.h.
61 std::lock_guard<std::mutex> guard(mu_);
62 for (
int i = 0; i < cache_.
size(); i++) {
63 if (
id == cache_[i].
id) {
64 retval = cache_[i].object;
65 if (cache_[i].
object !=
nullptr) {
72 ReferenceCount &rc = cache_.
back();
74 retval = rc.object = loader();
75 rc.count = (retval !=
nullptr) ? 1 : 0;
The documentation for this class was generated from the following file: