MXS-1506: Make heartbeat reads atomic
The old hkheartbeat variable was changed to the mxs_clock() function that simply wraps an atomic load of the variable. This allows it to be correctly read by MaxScale as well as opening up the possibility of converting the value load to a relaxed memory order read. Renamed the header and associated macros. Removed inclusion of the heartbeat header from the housekeeper header and added it to the files that were missing it.
This commit is contained in:
@ -17,20 +17,24 @@
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* The global housekeeper heartbeat value. This value is incremented
|
||||
* every 100 milliseconds and may be used for crude timing etc.
|
||||
* The global clock
|
||||
*
|
||||
* This value is incremented roughly every 100 milliseconds and may be used for
|
||||
* very crude timing. The crudeness is due to the fact that the housekeeper
|
||||
* thread does the updating of this value.
|
||||
*
|
||||
* @return The current clock tick
|
||||
*/
|
||||
|
||||
extern int64_t hkheartbeat;
|
||||
int64_t mxs_clock();
|
||||
|
||||
/**
|
||||
* Convert heartbeats to seconds
|
||||
*/
|
||||
#define HB_TO_SEC(a) ((int64_t)a / 10)
|
||||
#define MXS_CLOCK_TO_SEC(a) ((int64_t)a / 10)
|
||||
|
||||
/**
|
||||
* Convert seconds to heartbeats
|
||||
*/
|
||||
#define SEC_TO_HB(a) ((int64_t)a * 10)
|
||||
#define MXS_SEC_TO_CLOCK(a) ((int64_t)a * 10)
|
||||
|
||||
MXS_END_DECLS
|
||||
@ -19,7 +19,6 @@
|
||||
#include <maxscale/cdefs.h>
|
||||
#include <time.h>
|
||||
#include <maxscale/dcb.h>
|
||||
#include <maxscale/hk_heartbeat.h>
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user