summaryrefslogtreecommitdiff
path: root/lib/gras_impl/block_data.hpp
blob: 9fbf3eb11afd2d45ac34e44eb604f91109ff16c8 (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.

#ifndef INCLUDED_LIBGRAS_IMPL_BLOCK_DATA_HPP
#define INCLUDED_LIBGRAS_IMPL_BLOCK_DATA_HPP

#include <gras_impl/debug.hpp>
#include <gras_impl/bitset.hpp>
#include <gras_impl/token.hpp>
#include <gras_impl/stats.hpp>
#include <gras_impl/output_buffer_queues.hpp>
#include <gras_impl/input_buffer_queues.hpp>
#include <gras_impl/interruptible_thread.hpp>
#include <vector>
#include <set>
#include <map>

namespace gras
{

typedef boost::shared_ptr<PropertyRegistry> PropertyRegistrySptr;
struct PropertyRegistryPair
{
    PropertyRegistrySptr setter;
    PropertyRegistrySptr getter;
};

enum BlockState
{
    BLOCK_STATE_INIT,
    BLOCK_STATE_LIVE,
    BLOCK_STATE_DONE,
};

struct BlockData
{
    //per port properties
    std::vector<InputPortConfig> input_configs;
    std::vector<OutputPortConfig> output_configs;

    //work buffers for the new work interface
    Block::InputItems input_items;
    Block::OutputItems output_items;

    //track the subscriber counts
    std::vector<Token> input_tokens;
    std::vector<Token> output_tokens;
    BitSet inputs_done;
    BitSet outputs_done;
    std::set<Token> token_pool;

    //buffer queues and ready conditions
    InputBufferQueues input_queues;
    OutputBufferQueues output_queues;
    std::vector<bool> produce_outputs;
    BitSet inputs_available;
    std::vector<time_ticks_t> time_input_not_ready;
    std::vector<time_ticks_t> time_output_not_ready;

    //tag and msg tracking
    std::vector<bool> input_tags_changed;
    std::vector<std::vector<Tag> > input_tags;
    std::vector<size_t> num_input_msgs_read;
    std::vector<std::vector<PMCC> > input_msgs;

    //interruptible thread stuff
    bool interruptible_work;
    SharedThreadGroup thread_group;
    boost::shared_ptr<InterruptibleThread> interruptible_thread;

    //is the fg running?
    BlockState block_state;
    long buffer_affinity;

    std::vector<std::vector<OutputHintMessage> > output_allocation_hints;

    //property stuff
    std::map<std::string, PropertyRegistryPair> property_registry;

    BlockStats stats;
};

} //namespace gras

#endif /*INCLUDED_LIBGRAS_IMPL_BLOCK_DATA_HPP*/