https://github.com/sniper00/snowflake-cpp
A C++ port of Twitter's Snowflake id generation algorithm
https://github.com/sniper00/snowflake-cpp
generation-algorithm snowflake-cpp
Last synced: 10 months ago
JSON representation
A C++ port of Twitter's Snowflake id generation algorithm
- Host: GitHub
- URL: https://github.com/sniper00/snowflake-cpp
- Owner: sniper00
- License: mit
- Created: 2018-09-27T14:01:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-16T02:43:29.000Z (almost 5 years ago)
- Last Synced: 2025-03-25T20:21:40.405Z (10 months ago)
- Topics: generation-algorithm, snowflake-cpp
- Language: C++
- Homepage:
- Size: 4.88 KB
- Stars: 76
- Watchers: 4
- Forks: 25
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# snowflake-cpp
A C++ port of Twitter's Snowflake id generation algorithm
# Use
```cpp
using snowflake_t = snowflake<1534832906275L>;
snowflake_t uuid;
uuid.init(1, 1);
for (int64_t i = 0; i < 10000; ++i)
{
auto id = uuid.nextid();
std::cout << id << "\n";
}
```
# Use with lock
```cpp
using snowflake_t = snowflake<1534832906275L,std::mutex>;
snowflake_t uuid;
uuid.init(1, 1);
for (int64_t i = 0; i < 10000; ++i)
{
auto id = uuid.nextid();
std::cout << id << "\n";
}
```