id_generator.h
来自「ace开发环境 用来开发网络程序 其运用了设计模式、多平台、C++等多种知识」· C头文件 代码 · 共 63 行
H
63 行
/* -*- C++ -*- */// $Id: ID_Generator.h 53415 2003-11-09 04:12:10Z dhinton $// ============================================================================//// = LIBRARY// none//// = FILENAME// ID_Generator.h//// = AUTHOR// Nanbor Wang//// ============================================================================#ifndef ACE_ID_GENERATOR_H#define ACE_ID_GENERATOR_h#include "ace/config-all.h"#if !defined (ACE_LACKS_PRAGMA_ONCE)# pragma once#endif /* ACE_LACKS_PRAGMA_ONCE */#define ACE_OFFER_ID_LENGTH 21class ACE_ID_Generator // = TITLE // An unique ID generator. // // = DESCRIPTION // Generate an offer ID according to current time and avoid // duplicate ID. It guarantees ID uniqueness within a process, // i.e. no two threads may get the same ID string. Using a // similar method like the backery algorithm.{public: static char *get_new_id (char *id); // allocate a new ID string and point <id> to it.private: static void get_serial_id (time_t &t, size_t &s); // Atomically get info required to generate an offer ID. static ACE_SYNCH_MUTEX *get_lock (void); // Get the lock instance. static time_t last_time_; // Record the time last offer ID generated. static size_t last_number_; // Record serial number of last offer ID with same // generation time. static ACE_SYNCH_MUTEX *lock_; // mutex to access private member.};#endif /* ACE_ID_GENERATOR_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?