MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / Globals_GetCommandCtxs

Function Globals_GetCommandCtxs

src/globals.c:246–277  ·  view source on GitHub ↗

get all currently tracked CommandCtxs

Source from the content-addressed store, hash-verified

244
245// get all currently tracked CommandCtxs
246void Globals_GetCommandCtxs
247(
248 CommandCtx **commands, // array to populate
249 uint32_t *count // [input/output] number of entries in 'commands'
250) {
251 ASSERT(count != NULL);
252 ASSERT(commands != NULL);
253 ASSERT(_globals.command_ctxs != NULL);
254
255 // make a copy of the command contexts
256 uint32_t nthreads = ThreadPools_ThreadCount() + 1;
257 uint32_t cap = *count; // capacity of 'commands'
258 uint32_t found = 0; // number of command contexts found
259
260 // acquire write lock
261 pthread_rwlock_wrlock(&_globals.lock);
262
263 // increase ref count of each CommandCtx
264 for(uint32_t i = 0; i < nthreads && found < cap; i++) {
265 CommandCtx *cmd = _globals.command_ctxs[i];
266 if(cmd != NULL) {
267 CommandCtx_Incref(cmd);
268 commands[found++] = cmd;
269 }
270 }
271
272 // release lock
273 pthread_rwlock_unlock(&_globals.lock);
274
275 // update number of command contexts found
276 *count = found;
277}
278
279// free globals
280void Globals_Free(void) {

Callers 3

logCommandsFunction · 0.85
InfoFuncFunction · 0.85
_info_running_queriesFunction · 0.85

Calls 2

ThreadPools_ThreadCountFunction · 0.85
CommandCtx_IncrefFunction · 0.85

Tested by

no test coverage detected