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