1 #include <Base/Common/FiFoQueue.hh>
10 void* reader(
void* arg) {
14 for (
size_t i=0; i<1000000; i++) {
17 BIASASSERT(arr[a]!=1);
23 void* writer1(
void* arg) {
25 for (
int i=0; i<1000000; i++) {
32 void* writer2(
void* arg) {
34 for (
int i=1000000; i<2000000; i++) {
41 void* writer3(
void* arg) {
43 for (
int i=2000000; i<3000000; i++) {
50 void* writer4(
void* arg) {
52 for (
int i=3000000; i<4000000; i++) {
66 mut =
new pthread_mutex_t();
67 pthread_mutex_init(mut,NULL);
68 for (
int i=0; i<4000000; i++)
72 pthread_t threadId1,threadId2,threadId3,threadId4,
73 threadId5,threadId6,threadId7,threadId8;
74 pthread_create(&threadId1,NULL,&reader,(
void*)queue);
75 pthread_create(&threadId2,NULL,&reader,(
void*)queue);
76 pthread_create(&threadId3,NULL,&reader,(
void*)queue);
77 pthread_create(&threadId4,NULL,&reader,(
void*)queue);
78 pthread_create(&threadId5,NULL,&writer1,(
void*)queue);
79 pthread_create(&threadId6,NULL,&writer2,(
void*)queue);
80 pthread_create(&threadId7,NULL,&writer3,(
void*)queue);
81 pthread_create(&threadId8,NULL,&writer4,(
void*)queue);
84 pthread_join(threadId1,NULL);
85 pthread_join(threadId2,NULL);
86 pthread_join(threadId3,NULL);
87 pthread_join(threadId4,NULL);
88 pthread_join(threadId5,NULL);
89 pthread_join(threadId6,NULL);
90 pthread_join(threadId7,NULL);
91 pthread_join(threadId8,NULL);
This class implements a templated standard FiFo-queue for inter process communication (arbitrary numb...
int FetchSynced(T &item)
Fetch the oldest item from the queue.
int AppendSynced(T &item)
Append an datum as newest item.