You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

YitIdHelper.c 733 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930
  1. /*
  2. * 版权属于:yitter(yitter@126.com)
  3. * 开源地址:https://gitee.com/yitter/idgenerator
  4. */
  5. #include <stdlib.h>
  6. #include <stdint.h>
  7. #include "YitIdHelper.h"
  8. #include "idgen/IdGenerator.h"
  9. extern void SetIdGenerator(IdGeneratorOptions options) {
  10. SetOptions(options);
  11. }
  12. extern void SetWorkerId(uint32_t workerId) {
  13. IdGeneratorOptions options = BuildIdGenOptions(workerId);
  14. // SetOptions(options);
  15. SetIdGenerator(options);
  16. }
  17. extern uint64_t NextId() {
  18. return GetIdGenInstance()->NextId();
  19. // IdGenerator *generator = GetIdGenInstance();
  20. // uint64_t id = generator->NextId();
  21. // free(generator);
  22. // return id;
  23. }
  24. extern uint64_t TestId() {
  25. return 123456;
  26. }

雪花算法中非常好用的数字ID生成器