function create_work_threads changed
parent
414f20fa61
commit
b7dde81d1e
3
HISTORY
3
HISTORY
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
Version 1.42 2019-11-30
|
Version 1.42 2019-12-03
|
||||||
* add function get_gzip_command_filename
|
* add function get_gzip_command_filename
|
||||||
|
* function create_work_threads changed
|
||||||
|
|
||||||
Version 1.41 2019-09-30
|
Version 1.41 2019-09-30
|
||||||
* change CIDR network_bits range from [16, 32) to [10, 32)
|
* change CIDR network_bits range from [16, 32) to [10, 32)
|
||||||
|
|
|
||||||
|
|
@ -136,11 +136,12 @@ int init_pthread_attr(pthread_attr_t *pattr, const int stack_size)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int create_work_threads(int *count, void *(*start_func)(void *), \
|
int create_work_threads(int *count, void *(*start_func)(void *),
|
||||||
void *arg, pthread_t *tids, const int stack_size)
|
void **args, pthread_t *tids, const int stack_size)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
pthread_attr_t thread_attr;
|
pthread_attr_t thread_attr;
|
||||||
|
void **current_arg;
|
||||||
pthread_t *ptid;
|
pthread_t *ptid;
|
||||||
pthread_t *ptid_end;
|
pthread_t *ptid_end;
|
||||||
|
|
||||||
|
|
@ -151,16 +152,16 @@ int create_work_threads(int *count, void *(*start_func)(void *), \
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
ptid_end = tids + (*count);
|
ptid_end = tids + (*count);
|
||||||
for (ptid=tids; ptid<ptid_end; ptid++)
|
for (ptid=tids,current_arg=args; ptid<ptid_end; ptid++,current_arg++)
|
||||||
{
|
{
|
||||||
if ((result=pthread_create(ptid, &thread_attr, \
|
if ((result=pthread_create(ptid, &thread_attr,
|
||||||
start_func, arg)) != 0)
|
start_func, *current_arg)) != 0)
|
||||||
{
|
{
|
||||||
*count = ptid - tids;
|
*count = ptid - tids;
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, "
|
||||||
"create thread failed, startup threads: %d, " \
|
"create threads #%d fail, "
|
||||||
"errno: %d, error info: %s", \
|
"errno: %d, error info: %s",
|
||||||
__LINE__, *count, \
|
__LINE__, *count,
|
||||||
result, STRERROR(result));
|
result, STRERROR(result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ extern "C" {
|
||||||
int init_pthread_lock(pthread_mutex_t *pthread_lock);
|
int init_pthread_lock(pthread_mutex_t *pthread_lock);
|
||||||
int init_pthread_attr(pthread_attr_t *pattr, const int stack_size);
|
int init_pthread_attr(pthread_attr_t *pattr, const int stack_size);
|
||||||
|
|
||||||
int create_work_threads(int *count, void *(*start_func)(void *), \
|
int create_work_threads(int *count, void *(*start_func)(void *),
|
||||||
void *arg, pthread_t *tids, const int stack_size);
|
void **args, pthread_t *tids, const int stack_size);
|
||||||
int kill_work_threads(pthread_t *tids, const int count);
|
int kill_work_threads(pthread_t *tids, const int count);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue