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(...)); * */
| 75 | * |
| 76 | */ |
| 77 | robj *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 | |
| 84 | robj *makeObjectShared(const char *rgch, size_t cch) |
| 85 | { |
no test coverage detected