Skip to content

Commit e2bbbac

Browse files
committed
归整了代码格式
1 parent 5796deb commit e2bbbac

File tree

10 files changed

+427
-412
lines changed

10 files changed

+427
-412
lines changed

lib_acl/include/thread/acl_pthread.h

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,46 +117,49 @@ struct acl_pthread_condattr_t {
117117
struct timespec {
118118
time_t tv_sec; /* Seconds. */
119119
long int tv_nsec; /* Nanoseconds. */
120-
#if 0
121-
long int tv_msec; /* millisecond, add by zsx */
122-
#endif
123120
};
124121

125122
/* in acl_pthread.c */
126123
ACL_API void acl_pthread_end(void);
127-
ACL_API int acl_pthread_once(acl_pthread_once_t *once_control, void (*init_routine)(void));
128-
ACL_API int acl_pthread_key_create(acl_pthread_key_t *key_ptr, void (*destructor)(void*));
124+
ACL_API int acl_pthread_once(acl_pthread_once_t *once_control,
125+
void (*init_routine)(void));
126+
ACL_API int acl_pthread_key_create(acl_pthread_key_t *key_ptr,
127+
void (*destructor)(void*));
129128
ACL_API void *acl_pthread_getspecific(acl_pthread_key_t key);
130129
ACL_API int acl_pthread_setspecific(acl_pthread_key_t key, void *value);
131130
ACL_API int acl_pthread_attr_init(acl_pthread_attr_t *attr);
132-
ACL_API int acl_pthread_attr_setstacksize(acl_pthread_attr_t *attr, size_t stacksize);
133-
ACL_API int acl_pthread_attr_setdetachstate(acl_pthread_attr_t *attr, int detached);
131+
ACL_API int acl_pthread_attr_setstacksize(acl_pthread_attr_t *attr,
132+
size_t stacksize);
133+
ACL_API int acl_pthread_attr_setdetachstate(acl_pthread_attr_t *attr,
134+
int detached);
134135
ACL_API int acl_pthread_attr_destroy(acl_pthread_attr_t *thr_attr);
135136
ACL_API unsigned long acl_pthread_self(void);
136-
ACL_API int acl_pthread_create(acl_pthread_t *thread,
137-
acl_pthread_attr_t *attr,
138-
void * (*start_routine)(void *),
139-
void *arg);
137+
ACL_API int acl_pthread_create(acl_pthread_t *thread,
138+
acl_pthread_attr_t *attr, void * (*start_routine)(void *),
139+
void *arg);
140140
ACL_API int acl_pthread_detach(acl_pthread_t thread);
141141
ACL_API int acl_pthread_join(acl_pthread_t thread, void **thread_return);
142142

143143
/* in acl_pthread_mutex.c */
144144
ACL_API int acl_pthread_mutex_destroy(acl_pthread_mutex_t *mutex);
145-
ACL_API int acl_pthread_mutex_init(acl_pthread_mutex_t *mutex, const acl_pthread_mutexattr_t *mattr);
145+
ACL_API int acl_pthread_mutex_init(acl_pthread_mutex_t *mutex,
146+
const acl_pthread_mutexattr_t *mattr);
146147
ACL_API int acl_pthread_mutex_lock(acl_pthread_mutex_t *mutex);
147148
ACL_API int acl_pthread_mutex_unlock(acl_pthread_mutex_t *mutex);
148149

149150
#define acl_pthread_mutex_trylock acl_pthread_mutex_lock
150151

151152
/* in acl_pthread_cond.c */
152-
ACL_API int acl_pthread_cond_init(acl_pthread_cond_t *cond, acl_pthread_condattr_t *cond_attr);
153+
ACL_API int acl_pthread_cond_init(acl_pthread_cond_t *cond,
154+
acl_pthread_condattr_t *cond_attr);
153155
ACL_API acl_pthread_cond_t * acl_pthread_cond_create(void);
154156
ACL_API int acl_pthread_cond_destroy(acl_pthread_cond_t *cond);
155157
ACL_API int acl_pthread_cond_signal(acl_pthread_cond_t *cond);
156158
ACL_API int acl_pthread_cond_broadcast(acl_pthread_cond_t *cond);
157-
ACL_API int acl_pthread_cond_timedwait(acl_pthread_cond_t *cond, acl_pthread_mutex_t *mutex,
158-
const struct timespec *timeout);
159-
ACL_API int acl_pthread_cond_wait(acl_pthread_cond_t *cond, acl_pthread_mutex_t *mutex);
159+
ACL_API int acl_pthread_cond_timedwait(acl_pthread_cond_t *cond,
160+
acl_pthread_mutex_t *mutex, const struct timespec *timeout);
161+
ACL_API int acl_pthread_cond_wait(acl_pthread_cond_t *cond,
162+
acl_pthread_mutex_t *mutex);
160163

161164
#endif /* !ACL_HAS_PTHREAD */
162165

@@ -176,7 +179,8 @@ ACL_API int acl_pthread_atexit_remove(void *arg, void (*free_callback)(void*));
176179
ACL_API int acl_pthread_tls_set_max(int max);
177180
ACL_API int acl_pthread_tls_get_max(void);
178181
ACL_API void *acl_pthread_tls_get(acl_pthread_key_t *key_ptr);
179-
ACL_API int acl_pthread_tls_set(acl_pthread_key_t key, void *ptr, void (*free_fn)(void *));
182+
ACL_API int acl_pthread_tls_set(acl_pthread_key_t key, void *ptr,
183+
void (*free_fn)(void *));
180184
ACL_API int acl_pthread_tls_del(acl_pthread_key_t key);
181185
ACL_API void acl_pthread_tls_once_get(acl_pthread_once_t *control_once);
182186
ACL_API void acl_pthread_tls_once_set(acl_pthread_once_t control_once);

lib_acl/include/thread/acl_pthread_pool.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,17 @@ typedef struct acl_pthread_pool_attr_t {
5353
* @param idle_timeout {int} 工作线程空闲超时退出时间(秒)
5454
* @return {acl_pthread_pool_t*}, 如果不为空则表示成功,否则失败
5555
*/
56-
ACL_API acl_pthread_pool_t *acl_thread_pool_create(int threads_limit, int idle_timeout);
56+
ACL_API acl_pthread_pool_t *acl_thread_pool_create(
57+
int threads_limit, int idle_timeout);
5758

5859
/**
5960
* 创建一个线程池对象
6061
* @param attr {acl_pthread_pool_attr_t*} 线程池创建时的属性,如果该参数为空,
6162
* 则采用默认参数: ACL_PTHREAD_POOL_DEF_XXX
6263
* @return {acl_pthread_pool_t*}, 如果不为空则表示成功,否则失败
6364
*/
64-
ACL_API acl_pthread_pool_t *acl_pthread_pool_create(const acl_pthread_pool_attr_t *attr);
65+
ACL_API acl_pthread_pool_t *acl_pthread_pool_create(
66+
const acl_pthread_pool_attr_t *attr);
6567

6668
/**
6769
* 当队列堆积的任务数大于空闲线程数的2倍时. 通过此函数设置添加任务的
@@ -70,7 +72,8 @@ ACL_API acl_pthread_pool_t *acl_pthread_pool_create(const acl_pthread_pool_attr_
7072
* @param timewait_sec {int} 休眠 的时间值, 建议将此值设置为 1--5 秒内
7173
* @return {int} 成功返回 0, 失败返回 -1
7274
*/
73-
ACL_API int acl_pthread_pool_set_timewait(acl_pthread_pool_t *thr_pool, int timewait_sec);
75+
ACL_API int acl_pthread_pool_set_timewait(
76+
acl_pthread_pool_t *thr_pool, int timewait_sec);
7477

7578
/**
7679
* 添加注册函数,在线程创建后立即执行此初始化函数
@@ -245,21 +248,24 @@ ACL_API void acl_pthread_pool_attr_init(acl_pthread_pool_attr_t *attr);
245248
* @param attr {acl_pthread_pool_attr_t*}
246249
* @param size {size_t}
247250
*/
248-
ACL_API void acl_pthread_pool_attr_set_stacksize(acl_pthread_pool_attr_t *attr, size_t size);
251+
ACL_API void acl_pthread_pool_attr_set_stacksize(
252+
acl_pthread_pool_attr_t *attr, size_t size);
249253

250254
/**
251255
* 设置线程池属性中的最大线程数限制值
252256
* @param attr {acl_pthread_pool_attr_t*}
253257
* @param threads_limit {int} 线程池中的最大线程数
254258
*/
255-
ACL_API void acl_pthread_pool_attr_set_threads_limit(acl_pthread_pool_attr_t *attr, int threads_limit);
259+
ACL_API void acl_pthread_pool_attr_set_threads_limit(
260+
acl_pthread_pool_attr_t *attr, int threads_limit);
256261

257262
/**
258263
* 设置线程池属性中线程空闲超时值
259264
* @param attr {acl_pthread_pool_attr_t*}
260265
* @param idle_timeout {int} 线程空闲超时时间(秒)
261266
*/
262-
ACL_API void acl_pthread_pool_attr_set_idle_timeout(acl_pthread_pool_attr_t *attr, int idle_timeout);
267+
ACL_API void acl_pthread_pool_attr_set_idle_timeout(
268+
acl_pthread_pool_attr_t *attr, int idle_timeout);
263269

264270
#ifdef __cplusplus
265271
}

lib_acl/include/thread/acl_pthread_rwlock.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
6666
#define ACL_PTHREAD_RWLOCK_INITIALIZER NULL
6767

6868
struct acl_pthread_rwlock {
69-
acl_pthread_mutex_t lock; /* monitor lock acl_pthread_mutex_t */
70-
int state; /* 0 = idle >0 = # of readers -1 = writer */
71-
acl_pthread_cond_t read_signal;
72-
acl_pthread_cond_t write_signal;
73-
int blocked_writers;
69+
acl_pthread_mutex_t lock; /* monitor lock acl_pthread_mutex_t */
70+
int state; /* 0 = idle >0 = # of readers -1 = writer */
71+
acl_pthread_cond_t read_signal;
72+
acl_pthread_cond_t write_signal;
73+
int blocked_writers;
7474
};
7575

7676
struct acl_pthread_rwlockattr {
77-
int pshared;
77+
int pshared;
7878
};
7979

8080
typedef struct acl_pthread_rwlock *acl_pthread_rwlock_t;
@@ -84,17 +84,18 @@ typedef struct acl_pthread_rwlockattr *acl_pthread_rwlockattr_t;
8484
extern "C" {
8585
#endif
8686

87-
int acl_pthread_rwlock_destroy (acl_pthread_rwlock_t *);
88-
int acl_pthread_rwlock_init (acl_pthread_rwlock_t *, const acl_pthread_rwlockattr_t *);
89-
int acl_pthread_rwlock_rdlock (acl_pthread_rwlock_t *);
90-
int acl_pthread_rwlock_tryrdlock (acl_pthread_rwlock_t *);
91-
int acl_pthread_rwlock_trywrlock (acl_pthread_rwlock_t *);
92-
int acl_pthread_rwlock_unlock (acl_pthread_rwlock_t *);
93-
int acl_pthread_rwlock_wrlock (acl_pthread_rwlock_t *);
94-
int acl_pthread_rwlockattr_init (acl_pthread_rwlockattr_t *);
95-
int acl_pthread_rwlockattr_getpshared (const acl_pthread_rwlockattr_t *, int *);
96-
int acl_pthread_rwlockattr_setpshared (acl_pthread_rwlockattr_t *, int);
97-
int acl_pthread_rwlockattr_destroy (acl_pthread_rwlockattr_t *);
87+
ACL_API int acl_pthread_rwlock_destroy(acl_pthread_rwlock_t *);
88+
ACL_API int acl_pthread_rwlock_init(acl_pthread_rwlock_t *,
89+
const acl_pthread_rwlockattr_t *);
90+
ACL_API int acl_pthread_rwlock_rdlock(acl_pthread_rwlock_t *);
91+
ACL_API int acl_pthread_rwlock_tryrdlock(acl_pthread_rwlock_t *);
92+
ACL_API int acl_pthread_rwlock_trywrlock(acl_pthread_rwlock_t *);
93+
ACL_API int acl_pthread_rwlock_unlock(acl_pthread_rwlock_t *);
94+
ACL_API int acl_pthread_rwlock_wrlock(acl_pthread_rwlock_t *);
95+
ACL_API int acl_pthread_rwlockattr_init(acl_pthread_rwlockattr_t *);
96+
ACL_API int acl_pthread_rwlockattr_getpshared(const acl_pthread_rwlockattr_t *, int *);
97+
ACL_API int acl_pthread_rwlockattr_setpshared(acl_pthread_rwlockattr_t *, int);
98+
ACL_API int acl_pthread_rwlockattr_destroy(acl_pthread_rwlockattr_t *);
9899

99100
#if defined(__cplusplus)
100101
}

lib_acl/include/thread/acl_sem.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ struct ACL_SEM {
1515
unsigned int volatile count;
1616
};
1717

18-
ACL_API ACL_SEM *acl_sem_create2(const char *pathname, unsigned int initial_value);
18+
ACL_API ACL_SEM *acl_sem_create2(const char *pathname,
19+
unsigned int initial_value);
1920
ACL_API ACL_SEM *acl_sem_create(unsigned int initial_value);
2021
ACL_API void acl_sem_destroy(ACL_SEM *sem);
2122
ACL_API int acl_sem_wait_timeout(ACL_SEM *sem, unsigned int timeout);

0 commit comments

Comments
 (0)