@@ -31,25 +31,28 @@ This GREP is licensed as CC-BY-4.0; original author as stated above.
31
31
It is commonly requested feature to be able to set the property of a block,
32
32
accessible through setters, through stream tags.
33
33
34
- The implementation of that would under current circumstances not quite
34
+ The implementation of that would, under current circumstances, be not quite
35
35
straightforward. To illustrate the steps and decisions to be made in such a
36
36
situation, let's discuss how one would extend a simple block like "Interpolating
37
37
FIR Filter" block with both stream tag and message port setters accepting PMT
38
38
uniform vectors.
39
39
40
40
1 . Implement thread-safe native and message handling setters. This can either be
41
41
achieved by:
42
- - Having a ` private ` thread-unsafe native setter; acquiring the
43
- ` block::d_setlock ` mutex in a ` public ` setter and in the critical part of
44
- ` work ` and a PMT-accepting setter, both calling the thread-unsafe native
45
- setter. Register the PMT-accepting setter as message handler.
46
- - Implementing and registering a ` private ` message handler method, which
47
- accepts a PMT, extracts the native type from the that and is called by GNU
48
- Radio only when ` work ` is not currently running. Implement a native setter
49
- method, which converts the ` std::vector ` of taps to a PMT vector and posts
50
- it as a message to the own message port.
51
-
52
- In both cases, the developer implements both a "native" and a "PMT" type setter,
42
+ - Having a ` private ` thread-unsafe native setter
43
+ ` set_taps_unsafe(std::vector<tap_t>) ` ; acquiring the ` block::d_setlock `
44
+ mutex in a ` public ` setter ` set_taps(std::vector<tap_t>) ` and in the
45
+ critical part of ` work ` and a PMT-accepting setter `set_taps(const
46
+ pmt_t&)`, both calling the thread-unsafe native setter. Register the
47
+ PMT-accepting setter as message handler.
48
+ - Implementing and registering a ` private ` message handler method
49
+ ` set_taps(const pmt_t&) ` , which accepts a PMT, extracts the native type
50
+ from the that and is called by GNU Radio only when ` work ` is not currently
51
+ running. Implement a native setter ` set_taps(std::vector<tap_t>) ` method,
52
+ which converts the ` std::vector ` of taps to a PMT vector and posts it as a
53
+ message to the own message port.
54
+
55
+ In both cases, the developer implements * both* a "native" and a "PMT" type setter,
53
56
with one just being boilerplate code invoking the other. Both options have their
54
57
potential performance downsides, with overly coarse granularity, i.e. ` work `
55
58
call granularity, in case of the message handler, or a mutex acquisition
@@ -86,13 +89,13 @@ Add a protected `std::unordered_set<gr::property_setter> sensitivity_list`
86
89
member to ` gr::sync_block ` (later extension to ` gr::block ` nonwithstanding).
87
90
88
91
The set contains elements of a yet to be implemented type ` gr::property_setter ` .
89
- Its constructor takes a ` const std::string& key ` as well as a reference to a
92
+ Its constructor takes a ` const std::string& key ` as well as a
90
93
` std::function<bool(const type_of_property&)> underlying_setter ` . It has an
91
94
` operator(const type_of_property&) ` , which actually calls the thread-unsafe
92
95
setter. Furthermore, it has an ` operator(const pmt_t&) ` , which automatically
93
96
converts the PMT to the field type prior to setting the field. The hashing and
94
97
comparison methods necessary for ` unordered_set ` of the type are delegated to
95
- the PMT ` pmt::symbol(key) ` .
98
+ the PMT ` pmt::symbol(key) ` .
96
99
97
100
If ` sensitivity_list ` is not empty, the GNU Radio scheduling algorithm
98
101
(` run_one_iteration ` ), instead of directly calling into work, looks only for the
@@ -137,7 +140,7 @@ class sensitive_blk_impl : public sensitive_blk
137
140
};
138
141
```
139
142
140
- ## # Proposed Implementation of Types
143
+ ### Proposed Implementation of Types
141
144
142
145
```c++ namespace gnuradio::gr
143
146
{
@@ -169,13 +172,13 @@ class sensitive_blk_impl : public sensitive_blk
169
172
setter_type underlying_setter)
170
173
: property_setter(owner, key), setter(underlying_setter)
171
174
{
172
- owner->set_msg_handler([](const pmt_t& val) { this->operator(val); });
175
+ owner->set_msg_handler([](const pmt_t& val) { this->operator()( val); });
173
176
}
174
177
175
178
bool operator(const property_type& value) const
176
179
{
177
180
if (!setter(value)) {
178
- GR_LOG_WARN( owner->d_logger, key + " property_setter: failed setting"
181
+ owner->d_logger->warn("{} property_setter: failed setting", key);
179
182
return false;
180
183
}
181
184
return true;
@@ -185,6 +188,7 @@ class sensitive_blk_impl : public sensitive_blk
185
188
// int…
186
189
// Most elegant would be to have a templated pmt_basic::to<target_type>()
187
190
// operator?
191
+ // Does pmtf solve this?
188
192
/*
189
193
bool operator(const pmt::pmt_t& polymorph) const
190
194
{
0 commit comments