source: trunk/src/processing_queue.h @ 7

Last change on this file since 7 was 5, checked in by guillaumeb, 15 years ago

Réorganisation des dossiers

déplacement des fichiers source dans le sous dossier ./src
déplacement de systemc dans le sous-dossier ./lib

File size: 1.8 KB
Line 
1#ifndef PROCESSING_QUEUE_H
2#define PROCESSING_QUEUE_H
3
4#include <list>
5#include <iostream>
6#include "util.h"
7#include "address.h"
8
9using namespace std;
10
11enum ProcessingType
12{
13    INTERNAL_TIMEOUT,
14    EXTERNAL_WAIT
15};
16
17struct ProcessingElement {
18    // The data to store
19    Address address;
20
21    // Is the process calculating or waiting for external calculation
22    const ProcessingType processing_type;
23
24    // If the process is done by external calculation, is_ready should
25    // be true when the calculation is finished
26    bool is_ready;
27
28    // If the process is done by internal calculation, this represents
29    // the current timeout.
30    unsigned int latency;
31
32
33    inline friend ostream& operator << ( ostream& os,  ProcessingElement const & v ) {
34        if (v.processing_type == INTERNAL_TIMEOUT) {
35            os << v.address << "(timeout=" << v.latency << ")";
36        } else if (v.processing_type == EXTERNAL_WAIT) {
37            os << v.address << "(extern waiting)";
38        }
39        return os;
40    }
41   
42};
43
44class ProcessingQueue {
45    private:
46        unsigned int max_size;
47        unsigned int current_size;
48        list<ProcessingElement> elements;
49
50    public:
51        ProcessingQueue(int size) {
52            this->max_size = size;
53            this->current_size = 0;
54        }
55
56
57        // Prints the content of the queue
58        void print();
59
60        // marks an external request as ready for being sent
61        void mark_ready(Address &element);
62
63        // insert a request for internal processing, with
64        // specified timeout
65        void insert(const Address addr, unsigned int latency);
66
67        // insert a request for external processing.
68        // will be updated by
69        void insert(const Address addr);
70
71        Address* get_next_ready();
72
73        // Updates the timeout of all internal requests
74        void update_time();
75};
76
77#endif
78
Note: See TracBrowser for help on using the repository browser.