Skip to content

Commit 285b5be

Browse files
committed
Small refactor in get_thread_id function.
1 parent 78da23e commit 285b5be

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/execution/background_workers.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,10 @@ static bool _BGThread_PrepareExecution(RunQueueInfo *run_queue_info, RedisAI_Run
255255

256256
long BGWorker_GetThreadId() {
257257
void *thread_id = pthread_getspecific(ThreadIdKey);
258-
if (thread_id == NULL) {
259-
return -1;
260-
}
261-
// Return the as 0 based id.
262-
return (long)pthread_getspecific(ThreadIdKey) - 1;
258+
259+
// Return the 0 based id, if thread_id was NULL, we return -1 to indicates that
260+
// the caller is not RedisAI thread.
261+
return (long)(thread_id)-1;
263262
}
264263

265264
uintptr_t BGWorker_GetThreadsCount() { return BGWorkersCounter; }

0 commit comments

Comments
 (0)