| 32 | } |
| 33 | |
| 34 | bool FreqCtrlBucket::ApplyToken(int * for_apply, int count) { |
| 35 | uint32_t last_refill_time = (unsigned int) time(NULL); |
| 36 | last_refill_time = last_refill_time - last_refill_time % (db_token_.period); |
| 37 | |
| 38 | if (db_bucket_struct_.last_refill_time != last_refill_time) { |
| 39 | db_bucket_struct_.last_refill_time = last_refill_time; |
| 40 | db_bucket_struct_.read_bucket = db_token_.read_token; |
| 41 | db_bucket_struct_.write_bucket = db_token_.write_token; |
| 42 | } |
| 43 | |
| 44 | bool is_apply_ok = false; |
| 45 | if (*for_apply >= count) { |
| 46 | *for_apply -= count; |
| 47 | is_apply_ok = true; |
| 48 | } |
| 49 | return is_apply_ok; |
| 50 | } |
| 51 | |
| 52 | bool FreqCtrlBucket::ApplyReadToken(int count) { |
| 53 | return ApplyToken(&db_bucket_struct_.read_bucket, count); |
nothing calls this directly
no outgoing calls
no test coverage detected