forked from osqzss/gps-sdr-sim
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathArray_Queue.h
56 lines (46 loc) · 1.34 KB
/
Array_Queue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef Array_Queue_H
#define Array_Queue_H
/* Queue - Circular Array implementation in C++*/
/* Lock free for single producer and single consumer*/
#include<iostream>
#include <vector>
#include <complex>
#include"gpssim.h"
using namespace std;
#define MAX_SIZE 10 //maximum size of the array that will store Queue.
#define FRAME_SIZE 500000 //maximum size of the array that will store Queue.
#include <boost/thread.hpp>
typedef struct
{
gpstime_t time;
short * iq_ptr;
} time_and_samples;
// Creating a class named ArrayQueue.
class ArrayQueue
{
private:
time_and_samples A[MAX_SIZE];
short buffer[MAX_SIZE][FRAME_SIZE];
int front, rear;
// To check wheter Queue is empty or not
bool IsEmpty();
// To check whether Queue is full or not
bool IsFull();
// Inserts an element in queue at rear end
void Enqueue(gpstime_t time, short *sample, size_t length);
// Removes an element in Queue from front end.
void Dequeue();
/*
Printing the elements in queue from front to rear.
This function is only to test the code.
This is not a standard function for Queue implementation.
*/
void Print();
public:
// Constructor - set front and rear as -1.
// We are assuming that for an empty Queue, both front and rear will be -1.
ArrayQueue();
void BlockPush(gpstime_t time, short *sample, size_t length);
time_and_samples BlockPop();
};
#endif