not thread-safe
| 19 | |
| 20 | //not thread-safe |
| 21 | class FreqCtrlBucket { |
| 22 | public: |
| 23 | typedef struct tagDBToken { |
| 24 | int read_token; |
| 25 | int write_token; |
| 26 | int period; |
| 27 | } DBToken_t; |
| 28 | |
| 29 | typedef struct db_bucket { |
| 30 | int read_bucket; |
| 31 | int write_bucket; |
| 32 | uint32_t last_refill_time; |
| 33 | } DBBucket_t; |
| 34 | |
| 35 | public: |
| 36 | FreqCtrlBucket(); |
| 37 | |
| 38 | virtual ~FreqCtrlBucket(); |
| 39 | |
| 40 | public: |
| 41 | bool ApplyReadToken(int count); |
| 42 | |
| 43 | bool ApplyWriteToken(int count); |
| 44 | |
| 45 | void Refill(); |
| 46 | |
| 47 | void Sedb_token(const DBToken_t & db_token); |
| 48 | |
| 49 | bool HasReadToken(); |
| 50 | |
| 51 | bool HasWriteToken(); |
| 52 | |
| 53 | private: |
| 54 | bool ApplyToken(int * for_apply, int count); |
| 55 | |
| 56 | bool HasToken(int * for_check); |
| 57 | private: |
| 58 | DBToken_t db_token_; |
| 59 | |
| 60 | DBBucket_t db_bucket_struct_; |
| 61 | }; |
| 62 | |
| 63 | class FreqCtrlConfig : public phxsql::PhxBaseConfig { |
| 64 |
nothing calls this directly
no outgoing calls
no test coverage detected