add func: sf_get_random_thread_data_ex
parent
8b11d63ac6
commit
02adaac3e5
|
|
@ -621,3 +621,11 @@ void sf_enable_thread_notify_ex(SFContext *sf_context, const bool enabled)
|
|||
thread_data->notify.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
struct nio_thread_data *sf_get_random_thread_data_ex(SFContext *sf_context)
|
||||
{
|
||||
uint32_t index;
|
||||
index = (uint32_t)((uint64_t)sf_context->work_threads *
|
||||
(uint64_t)rand() / (uint64_t)RAND_MAX);
|
||||
return sf_context->thread_data + index;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,12 @@ static inline void sf_enable_realloc_task_buffer_ex(SFContext *sf_context,
|
|||
#define sf_enable_realloc_task_buffer(enabled) \
|
||||
sf_enable_realloc_task_buffer_ex(&g_sf_context, enabled)
|
||||
|
||||
struct nio_thread_data *sf_get_random_thread_data_ex(SFContext *sf_context);
|
||||
|
||||
#define sf_get_random_thread_data() \
|
||||
sf_get_random_thread_data_ex(&g_sf_context)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue