Commit 77311570 authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

Don't use atomic add for not critical statistics.

parent 1febfbe8
...@@ -669,8 +669,6 @@ extern pthread_t shutdown_th, main_th, signal_th; ...@@ -669,8 +669,6 @@ extern pthread_t shutdown_th, main_th, signal_th;
#define thread_safe_increment(V,L) atomic_add(1,(atomic_t*) &V); #define thread_safe_increment(V,L) atomic_add(1,(atomic_t*) &V);
#define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V); #define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V);
#define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V); #define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V);
#define statistic_increment(V,L) thread_safe_increment((V),(L))
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
#else #else
#define thread_safe_increment(V,L) \ #define thread_safe_increment(V,L) \
pthread_mutex_lock((L)); (V)++; pthread_mutex_unlock((L)); pthread_mutex_lock((L)); (V)++; pthread_mutex_unlock((L));
...@@ -678,6 +676,7 @@ extern pthread_t shutdown_th, main_th, signal_th; ...@@ -678,6 +676,7 @@ extern pthread_t shutdown_th, main_th, signal_th;
pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L)); pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
#define thread_safe_sub(V,C,L) \ #define thread_safe_sub(V,C,L) \
pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L)); pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
#endif /* HAVE_ATOMIC_ADD */
#ifdef SAFE_STATISTICS #ifdef SAFE_STATISTICS
#define statistic_increment(V,L) thread_safe_increment((V),(L)) #define statistic_increment(V,L) thread_safe_increment((V),(L))
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L)) #define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
...@@ -685,7 +684,6 @@ extern pthread_t shutdown_th, main_th, signal_th; ...@@ -685,7 +684,6 @@ extern pthread_t shutdown_th, main_th, signal_th;
#define statistic_increment(V,L) (V)++ #define statistic_increment(V,L) (V)++
#define statistic_add(V,C,L) (V)+=(C) #define statistic_add(V,C,L) (V)+=(C)
#endif /* SAFE_STATISTICS */ #endif /* SAFE_STATISTICS */
#endif /* HAVE_ATOMIC_ADD */
#endif /* thread_safe_increment */ #endif /* thread_safe_increment */
#ifdef __cplusplus #ifdef __cplusplus
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment