add macros: FC_ABS and FC_NEGATIVE

storage_pool
YuQing 2021-03-10 14:38:09 +08:00
parent 3f15be8d92
commit 04226e28fc
4 changed files with 9 additions and 4 deletions

View File

@ -1,4 +1,7 @@
Version 1.49 2021-03-10
* add macros: FC_ABS and FC_NEGATIVE
Version 1.48 2021-02-01
* fast_buffer.[hc]: add function fast_buffer_append_binary
* fc_check_mkdir_ex return 0 when mkdir with errno EEXIST

View File

@ -133,6 +133,8 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind);
#define FC_IS_LOWER_LETTER(ch) (ch >= 'a' && ch <= 'z')
#define FC_MIN(v1, v2) (v1 < v2 ? v1 : v2)
#define FC_MAX(v1, v2) (v1 > v2 ? v1 : v2)
#define FC_ABS(n) (n >= 0 ? (n) : -1 * (n))
#define FC_NEGATIVE(n) (n <= 0 ? (n) : -1 * (n))
#define FC_TIME_UNIT_SECOND 's' //second
#define FC_TIME_UNIT_MSECOND 'm' //millisecond

View File

@ -96,8 +96,8 @@ struct fast_task_info
int (*continue_callback)(struct fast_task_info *task); //for continue stage
volatile int8_t reffer_count;
volatile int8_t canceled; //if task canceled
int connect_timeout; //for client side
int network_timeout;
short connect_timeout; //for client side
short network_timeout;
int64_t req_count; //request count
TaskFinishCallback finish_callback;
struct nio_thread_data *thread_data;

View File

@ -28,7 +28,7 @@
#include "fastcommon/fast_allocator.h"
#define THREAD_COUNT 8
#define LOOP_COUNT (1000)
#define LOOP_COUNT (100)
static volatile int thread_count = THREAD_COUNT;
static pthread_mutex_t lock;
@ -41,7 +41,7 @@ void *thread_func(void *arg)
sum = 0;
for (k=1; k<=LOOP_COUNT; k++) {
pthread_mutex_lock(&lock);
usleep(10 * 1000);
usleep(100 * 1000);
sum += k;
pthread_mutex_unlock(&lock);
}