fusion/common/utils/ratelimit.c

30 lines
902 B
C
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**********************************************************************************************
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()");
}