根据自己理解的oracle sequence的方式,实现了下,并做了性能测试,
测试环境为公司报废的笔记本电脑 dell E4300 ubuntu 13 64位系统.
代码实现:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/time.h>
/**
* created by gongbo.yxh
seq mod
2013-06-11
**/
#define SEQ_CACHE_SIZE 1000
#define START 1
//两个seq cache
unsigned long long * seq_buf;
unsigned long long int *seq_pointer;
int isprepared = 1; //是否准备好
unsigned long long int seq_extend_next_val = SEQ_CACHE_SIZE + 1;
int is_consumer_head = 1; //在定长数组中,是否生产者的指针在前面
unsigned long long int *seq_producer; //生产者指针
unsigned long long int *seq_consumer; //消费者
/**
初始话,将两个数组构造好