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
|
#ifndef CHUNK_QUEUE
#define CHUNK_QUEUE
#include <pthread.h>
#include <deque>
#include <davix.hpp>
#define DEFAULT_WAIT_TIME 5
const int STARTED = 1;
const int STOPPED = 2;
class ChunkQueue
{
public:
ChunkQueue();
~ChunkQueue();
struct worktoken
{
long length;
long offset;
DAVIX_FD* fd;
};
void pushOp(long len, long oset, DAVIX_FD* davfd);
struct worktoken *getOp();
void StopThreads();
int GetQueueSize();
int GetQueueState();
void SetQueueState(int new_state);
private:
/// Queue of the pending operations
std::deque<worktoken*> workqueue;
pthread_mutex_t workmutex;
pthread_cond_t popconvar;
pthread_cond_t pushconvar;
int state;
};
#endif
|