Skip to content

littleningmeng/c-token-bucket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c-token-bucket

a ratelimiter with token bucket written by c
lock-free with CAS

#include "token_bucket.h"
#include <stdio.h>

int main(int argc, char *argv[]) {
  token_bucket_t *tb;
  tb = token_bucket_create(1, 1); // create with QPS=1 and bucket size=1
  while(1) {
    token_bucket_take(tb, 1); // take 1 token per second
    printf("hello\n");
  }
  token_bucket_destroy(tb);
  return 0;
}

About

a ratelimiter with token bucket written by c

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published