MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / makeObjectShared

Function makeObjectShared

src/object.cpp:77–82  ·  view source on GitHub ↗

Set a special refcount in the object to make it "shared": * incrRefCount and decrRefCount() will test for this special refcount * and will not touch the object. This way it is free to access shared * objects such as small integers from different threads without any * mutex. * * A common patter to create shared objects: * * robj *myobject = makeObjectShared(createObject(...)); * */

Source from the content-addressed store, hash-verified

75 *
76 */
77robj *makeObjectShared(robj *o) {
78 serverAssert(o->getrefcount(std::memory_order_relaxed) == 1);
79 serverAssert(!o->FExpires());
80 o->setrefcount(OBJ_SHARED_REFCOUNT);
81 return o;
82}
83
84robj *makeObjectShared(const char *rgch, size_t cch)
85{

Callers 1

createSharedObjectsFunction · 0.85

Calls 5

createObjectFunction · 0.85
sdsnewlenFunction · 0.85
getrefcountMethod · 0.80
FExpiresMethod · 0.80
setrefcountMethod · 0.80

Tested by

no test coverage detected