add function fc_sleep_us

remotes/origin/fstore_storage_engine
YuQing 2022-09-27 20:28:29 +08:00
parent 117b723274
commit cf66174cf9
2 changed files with 20 additions and 0 deletions

View File

@ -1,4 +1,7 @@
Version 1.62 2022-09-27
* add function fc_sleep_us
Version 1.61 2022-09-21
* get_base_path_from_conf_file_ex support parameter: noent_log_level
* add function common_blocked_queue_push_chain

View File

@ -1176,6 +1176,23 @@ bool fc_path_contains(const string_t *path, const string_t *needle,
int *result);
/** sleep in microseconds
* parameters:
* microseconds: microseconds to sleep
* return: 0 for success, != 0 for fail
*/
static inline int fc_sleep_us(const int microseconds)
{
struct timespec ts;
ts.tv_sec = microseconds / (1000 * 1000);
ts.tv_nsec = (microseconds % (1000 * 1000)) * 1000;
if (nanosleep(&ts, NULL) == 0) {
return 0;
} else {
return errno != 0 ? errno : EINVAL;
}
}
/** sleep in milliseconds
* parameters:
* milliseconds: milliseconds to sleep