MCPcopy Create free account
hub / github.com/creatale/node-dv / Get

Method Get

deps/tesseract/ccutil/object_cache.h:60–82  ·  view source on GitHub ↗

Return a pointer to the object identified by id. If we haven't yet loaded the object, use loader to load it. If loader fails to load it, record a NULL entry in the cache and return NULL -- further attempts to load will fail (even with a different loader) until DeleteUnusedObjects() is called. We delete the given loader.

Source from the content-addressed store, hash-verified

58 // with a different loader) until DeleteUnusedObjects() is called.
59 // We delete the given loader.
60 T *Get(STRING id,
61 TessResultCallback<T *> *loader) {
62 T *retval = NULL;
63 mu_.Lock();
64 for (int i = 0; i < cache_.size(); i++) {
65 if (id == cache_[i].id) {
66 retval = cache_[i].object;
67 if (cache_[i].object != NULL) {
68 cache_[i].count++;
69 }
70 mu_.Unlock();
71 delete loader;
72 return retval;
73 }
74 }
75 cache_.push_back(ReferenceCount());
76 ReferenceCount &rc = cache_.back();
77 rc.id = id;
78 retval = rc.object = loader->Run();
79 rc.count = (retval != NULL) ? 1 : 0;
80 mu_.Unlock();
81 return retval;
82 }
83
84 // Decrement the count for t.
85 // Return whether we knew about the given pointer.

Callers 3

NAN_SETTERFunction · 0.80
NAN_METHODFunction · 0.80
GetSquishedDawgMethod · 0.80

Calls 6

ReferenceCountClass · 0.85
LockMethod · 0.45
sizeMethod · 0.45
UnlockMethod · 0.45
push_backMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected