initial commit
This commit is contained in:
29
common/utils/ratelimit.c
Executable file
29
common/utils/ratelimit.c
Executable file
@@ -0,0 +1,29 @@
|
||||
/**********************************************************************************************
|
||||
File name : ratelimit.h
|
||||
Module : common
|
||||
Author :
|
||||
Copyright :
|
||||
Version : 0.1
|
||||
Created on : 2021-11-18
|
||||
Creator : amir.liang
|
||||
Description :
|
||||
以一定的速率执行入参函数, ratelimit(func()); 每次call这个调用,默认每5秒最多执行一次func()
|
||||
Modify History:
|
||||
1. Date: Author: Modification:
|
||||
************************************************************************************************/
|
||||
#include "ratelimit.h"
|
||||
|
||||
static void retalimit_delay(){
|
||||
hv_msleep(500);
|
||||
}
|
||||
void retalimit_test()
|
||||
{
|
||||
uint64_t start = gettimeofday_ms();
|
||||
LOG_TIME(retalimit_delay());
|
||||
while(gettimeofday_ms() - start < 1000){
|
||||
ratelimit(printf("%s test\n", __func__));
|
||||
}
|
||||
LOG_TIME("retalimit_delay()");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user