jobid generate
This commit is contained in:
parent
9ff857db9f
commit
f3f6a78b07
7 changed files with 187 additions and 2 deletions
23
src/include/idgen.h
Normal file
23
src/include/idgen.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#if !defined(_IDGEN_H_)
|
||||
|
||||
#define _IDGEN_H_ 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "mylock.h"
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
time_t timestamp;
|
||||
uint32_t sequence;
|
||||
} idgen_ctx_t;
|
||||
|
||||
extern int idgen_ctx_init(idgen_ctx_t*);
|
||||
extern int idgen(idgen_ctx_t*, size_t, size_t, size_t, uint64_t*);
|
||||
extern void idgen_ctx_fini(idgen_ctx_t*);
|
||||
|
||||
#endif
|
||||
|
|
@ -20,6 +20,8 @@
|
|||
| (((uint64_t)timestamp) << TIMESTAMP_SHIFT) \
|
||||
| (((uint64_t)tag) << TAG_SHIFT) | sequence)
|
||||
|
||||
#define ROUNDUP(v, bits) (((v) + UMAX_BITS(bits)) & ~UMAX_BITS(bits))
|
||||
|
||||
#define xce_use(x) (void)(x)
|
||||
|
||||
#define float_near_zero (0.000001)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue