summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/include/gnuradio/buffer_reader_sm.h
blob: 627bfd85826b479a3ab0d0c36fb405b63eb0f824 (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
/* -*- c++ -*- */
/*
 * Copyright 2004,2009-2011,2013 Free Software Foundation, Inc.
 *
 * This file is part of GNU Radio
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 */

#ifndef INCLUDED_GR_RUNTIME_BUFFER_READER_SM_H
#define INCLUDED_GR_RUNTIME_BUFFER_READER_SM_H

#include <gnuradio/api.h>
#include <gnuradio/buffer.h>
#include <gnuradio/buffer_reader.h>
#include <gnuradio/logger.h>
#include <gnuradio/runtime_types.h>
#include <gnuradio/tags.h>
#include <gnuradio/thread/thread.h>
#include <boost/weak_ptr.hpp>
#include <map>
#include <memory>

namespace gr {

class GR_RUNTIME_API buffer_reader_sm : public buffer_reader
{
public:
    ~buffer_reader_sm();

    /*!
     * \brief Return number of items available for reading.
     */
    virtual int items_available(); // const

    /*!
     * \brief Return true if thread is ready to call input_blocked_callback,
     * false otherwise
     */
    virtual bool input_blkd_cb_ready(int items_required) const;

    /*!
     * \brief Callback function that the scheduler will call when it determines
     * that the input is blocked
     */
    virtual bool input_blocked_callback(int items_required, int items_avail);

private:
    friend class buffer;
    friend class buffer_double_mapped;
    friend class buffer_single_mapped;

    friend GR_RUNTIME_API buffer_reader_sptr buffer_add_reader(buffer_sptr buf,
                                                               int nzero_preload,
                                                               block_sptr link,
                                                               int delay);

    //! constructor is private.  Use gr::buffer::add_reader to create instances
    buffer_reader_sm(buffer_sptr buffer, unsigned int read_index, block_sptr link);
};

} // namespace gr

#endif /* INCLUDED_GR_RUNTIME_BUFFER_READER_SM_H */