MCPcopy Create free account
hub / github.com/F-Stack/f-stack / RM_GetDetachedThreadSafeContext

Function RM_GetDetachedThreadSafeContext

app/redis-6.2.6/src/module.c:5788–5796  ·  view source on GitHub ↗

Return a detached thread safe context that is not associated with any * specific blocked client, but is associated with the module's context. * * This is useful for modules that wish to hold a global context over * a long term, for purposes such as logging. */

Source from the content-addressed store, hash-verified

5786 * This is useful for modules that wish to hold a global context over
5787 * a long term, for purposes such as logging. */
5788RedisModuleCtx *RM_GetDetachedThreadSafeContext(RedisModuleCtx *ctx) {
5789 RedisModuleCtx *new_ctx = zmalloc(sizeof(*new_ctx));
5790 RedisModuleCtx empty = REDISMODULE_CTX_INIT;
5791 memcpy(new_ctx,&empty,sizeof(empty));
5792 new_ctx->module = ctx->module;
5793 new_ctx->flags |= REDISMODULE_CTX_THREAD_SAFE;
5794 new_ctx->client = createClient(NULL);
5795 return new_ctx;
5796}
5797
5798/* Release a thread safe context. */
5799void RM_FreeThreadSafeContext(RedisModuleCtx *ctx) {

Callers

nothing calls this directly

Calls 3

zmallocFunction · 0.85
createClientFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected