Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 559 Bytes

README.md

File metadata and controls

30 lines (24 loc) · 559 Bytes

snowflake-cpp

A C++ port of Twitter's Snowflake id generation algorithm

Use

    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

    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";
    }