File: chunk_queue.h

package info (click to toggle)
davix 0.8.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,184 kB
  • sloc: ansic: 164,612; cpp: 38,741; python: 17,726; perl: 14,124; sh: 13,458; xml: 3,567; makefile: 1,959; javascript: 885; pascal: 570; lisp: 7
file content (49 lines) | stat: -rw-r--r-- 752 bytes parent folder | download | duplicates (5)
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