Skip to content

SleepyMode/Snowflake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Snowflake

C++ header-only Implementation of Twitter's Snowflake algorithm.

Terminology

  • Instances are referred to as "Machine Identifiers" (.machineId)
  • Sequences are referred to as "Worker Identifiers" (.workerId)

Usage

Sample usage can be found in test.cc. Make sure to initialize the library with SnowflakeId::initialize prior to using (w/ epoch and machine identifier).

Example:

int main(int argc, char* argv[], char* envp[])
{
	SnowflakeId::initialize(0, 50);
	SnowflakeId identifier = SnowflakeId::generate();
	std::cout << identifier.implode() << std::endl;
}