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

Function RM_ThreadSafeContextTryLock

src/module.cpp:5948–5957  ·  view source on GitHub ↗

Similar to RM_ThreadSafeContextLock but this function * would not block if the server lock is already acquired. * * If successful (lock acquired) REDISMODULE_OK is returned, * otherwise REDISMODULE_ERR is returned and errno is set * accordingly. */

Source from the content-addressed store, hash-verified

5946 * otherwise REDISMODULE_ERR is returned and errno is set
5947 * accordingly. */
5948int RM_ThreadSafeContextTryLock(RedisModuleCtx *ctx) {
5949 UNUSED(ctx);
5950
5951 int res = moduleTryAcquireGIL(false /*fServerThread*/, true /*fExclusive*/);
5952 if(res != 0) {
5953 errno = res;
5954 return REDISMODULE_ERR;
5955 }
5956 return REDISMODULE_OK;
5957}
5958
5959/* Release the server lock after a thread safe API call was executed. */
5960void RM_ThreadSafeContextUnlock(RedisModuleCtx *ctx) {

Callers

nothing calls this directly

Calls 1

moduleTryAcquireGILFunction · 0.85

Tested by

no test coverage detected