MCPcopy Create free account
hub / github.com/Tencent/phxsql / FreqCtrlBucket

Class FreqCtrlBucket

phxsqlproxy/plugin/requestfilter/freqctrlconfig.h:21–61  ·  view source on GitHub ↗

not thread-safe

Source from the content-addressed store, hash-verified

19
20//not thread-safe
21class 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
63class FreqCtrlConfig : public phxsql::PhxBaseConfig {
64

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected