OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [common/] [async_tqueue.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sergeykhbr
/*
2
 *  Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
3
 *
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
5
 *  you may not use this file except in compliance with the License.
6
 *  You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *  Unless required by applicable law or agreed to in writing, software
11
 *  distributed under the License is distributed on an "AS IS" BASIS,
12
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *  See the License for the specific language governing permissions and
14
 *  limitations under the License.
15 3 sergeykhbr
 */
16
 
17
#ifndef __DEBUGGER_ASYNC_TQUEUE_H__
18
#define __DEBUGGER_ASYNC_TQUEUE_H__
19
 
20 4 sergeykhbr
#include <api_types.h>
21
#include <iface.h>
22
#include <attribute.h>
23 3 sergeykhbr
 
24
namespace debugger {
25
 
26
class AsyncTQueueType {
27 4 sergeykhbr
 public:
28 3 sergeykhbr
    AsyncTQueueType();
29
    ~AsyncTQueueType();
30
 
31 4 sergeykhbr
    /** Power ON/OFF cycle */
32
    void hardReset();
33 3 sergeykhbr
 
34 4 sergeykhbr
    /** Thread safe method of the callbacks registration */
35
    void put(AttributeType *item);
36
 
37 3 sergeykhbr
    /** push registered to the main queue */
38
    void pushPreQueued();
39
 
40
    /** Reset proccessed counter at the begining of each iteration */
41
    void initProc();
42
 
43 4 sergeykhbr
 protected:
44
    AttributeType item_;
45
    AttributeType stepQueue_;
46
    AttributeType stepPreQueued_;
47
    unsigned curIdx_;
48
    unsigned preLen_;
49
    unsigned curLen_;    // to avoid reallocation
50
    mutex_def mutex_;
51
};
52
 
53
 
54
class ClockAsyncTQueueType : public AsyncTQueueType {
55
 public:
56
    ClockAsyncTQueueType();
57
 
58
    /** Thread safe method of the callbacks registration */
59
    void put(uint64_t time, IFace *cb);
60
 
61 3 sergeykhbr
    /**
62
     * Get next registered interface with counter less or equal to 'step_cnt'
63
     */
64
    IFace *getNext(uint64_t step_cnt);
65
 
66 4 sergeykhbr
 private:
67 3 sergeykhbr
    enum QueueItemNames {
68 4 sergeykhbr
        Queue_Time,
69
        Queue_IFace,
70 3 sergeykhbr
        Queue_Total
71
    };
72
};
73
 
74 4 sergeykhbr
 
75
class GuiAsyncTQueueType : public AsyncTQueueType {
76
 public:
77
    GuiAsyncTQueueType();
78
 
79
    /** Thread safe method of the callbacks registration */
80
    void put(IFace *src, AttributeType *cmd, bool silent);
81
    bool getNext(IFace **src, AttributeType &cmd, bool &silent);
82
    void remove(IFace *src);
83
 
84
 private:
85
    enum QueueItemNames {
86
        Queue_Source,
87
        Queue_Command,
88
        Queue_Silent,
89
        Queue_Total
90
    };
91
    int dbg_cnt_;
92
};
93
 
94 3 sergeykhbr
}  // namespace debugger
95
 
96
#endif  // __DEBUGGER_ASYNC_TQUEUE_H__

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.