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 651 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
4 years ago
4 years ago
12345678910111213141516171819202122232425
  1. /*
  2. * 版权属于:yitter(yitter@126.com)
  3. * 开源地址:https://github.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. SetIdGenerator(options);
  15. }
  16. extern int64_t NextId() {
  17. return GetIdGenInstance()->NextId();
  18. // IdGenerator *generator = GetIdGenInstance();
  19. // uint64_t id = generator->NextId();
  20. // free(generator);
  21. // return id;
  22. }