Lock* IxManager_make_merge_lock(IndexManager *self) { ZombieCharBuf *merge_lock_name = ZCB_WRAP_STR("merge", 5); LockFactory *lock_factory = S_obtain_lock_factory(self); return LockFact_Make_Lock(lock_factory, (CharBuf*)merge_lock_name, self->merge_lock_timeout, self->merge_lock_interval); }
Lock* IxManager_make_deletion_lock(IndexManager *self) { ZombieCharBuf *lock_name = ZCB_WRAP_STR("deletion", 8); LockFactory *lock_factory = S_obtain_lock_factory(self); return LockFact_Make_Lock(lock_factory, (CharBuf*)lock_name, self->deletion_lock_timeout, self->deletion_lock_interval); }
Lock* IxManager_Make_Merge_Lock_IMP(IndexManager *self) { IndexManagerIVARS *const ivars = IxManager_IVARS(self); String *merge_lock_name = SSTR_WRAP_C("merge"); LockFactory *lock_factory = S_obtain_lock_factory(self); return LockFact_Make_Lock(lock_factory, merge_lock_name, ivars->merge_lock_timeout, ivars->merge_lock_interval); }
Lock* IxManager_Make_Deletion_Lock_IMP(IndexManager *self) { IndexManagerIVARS *const ivars = IxManager_IVARS(self); String *lock_name = SSTR_WRAP_C("deletion"); LockFactory *lock_factory = S_obtain_lock_factory(self); return LockFact_Make_Lock(lock_factory, lock_name, (int32_t)ivars->deletion_lock_timeout, (int32_t)ivars->deletion_lock_interval); }
Lock* IxManager_make_snapshot_read_lock(IndexManager *self, const CharBuf *filename) { ZombieCharBuf *lock_name = ZCB_WRAP(filename); LockFactory *lock_factory = S_obtain_lock_factory(self); if ( !CB_Starts_With_Str(filename, "snapshot_", 9) || !CB_Ends_With_Str(filename, ".json", 5) ) { THROW(ERR, "Not a snapshot filename: %o", filename); } // Truncate ".json" from end of snapshot file name. ZCB_Chop(lock_name, sizeof(".json") - 1); return LockFact_Make_Shared_Lock(lock_factory, (CharBuf*)lock_name, 1000, 100); }
Lock* IxManager_Make_Snapshot_Read_Lock_IMP(IndexManager *self, String *filename) { LockFactory *lock_factory = S_obtain_lock_factory(self); if (!Str_Starts_With_Utf8(filename, "snapshot_", 9) || !Str_Ends_With_Utf8(filename, ".json", 5) ) { THROW(ERR, "Not a snapshot filename: %o", filename); } // Truncate ".json" from end of snapshot file name. size_t lock_name_len = Str_Length(filename) - (sizeof(".json") - 1); String *lock_name = Str_SubString(filename, 0, lock_name_len); Lock *lock = LockFact_Make_Shared_Lock(lock_factory, lock_name, 1000, 100); DECREF(lock_name); return lock; }