Skip to content

Commit a75594f

Browse files
committed
be more specific
Signed-off-by: Marcus Müller <marcus@hostalia.de>
1 parent 205abb4 commit a75594f

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

grep-9999-tag-sensitivity-list.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,28 @@ This GREP is licensed as CC-BY-4.0; original author as stated above.
3131
It is commonly requested feature to be able to set the property of a block,
3232
accessible through setters, through stream tags.
3333

34-
The implementation of that would under current circumstances not quite
34+
The implementation of that would, under current circumstances, be not quite
3535
straightforward. To illustrate the steps and decisions to be made in such a
3636
situation, let's discuss how one would extend a simple block like "Interpolating
3737
FIR Filter" block with both stream tag and message port setters accepting PMT
3838
uniform vectors.
3939

4040
1. Implement thread-safe native and message handling setters. This can either be
4141
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,
5356
with one just being boilerplate code invoking the other. Both options have their
5457
potential performance downsides, with overly coarse granularity, i.e. `work`
5558
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`
8689
member to `gr::sync_block` (later extension to `gr::block` nonwithstanding).
8790

8891
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
9093
`std::function<bool(const type_of_property&)> underlying_setter`. It has an
9194
`operator(const type_of_property&)`, which actually calls the thread-unsafe
9295
setter. Furthermore, it has an `operator(const pmt_t&)`, which automatically
9396
converts the PMT to the field type prior to setting the field. The hashing and
9497
comparison methods necessary for `unordered_set` of the type are delegated to
95-
the PMT `pmt::symbol(key)`.
98+
the PMT `pmt::symbol(key)`.
9699

97100
If `sensitivity_list` is not empty, the GNU Radio scheduling algorithm
98101
(`run_one_iteration`), instead of directly calling into work, looks only for the
@@ -137,7 +140,7 @@ class sensitive_blk_impl : public sensitive_blk
137140
};
138141
```
139142
140-
## #Proposed Implementation of Types
143+
### Proposed Implementation of Types
141144
142145
```c++ namespace gnuradio::gr
143146
{
@@ -169,13 +172,13 @@ class sensitive_blk_impl : public sensitive_blk
169172
setter_type underlying_setter)
170173
: property_setter(owner, key), setter(underlying_setter)
171174
{
172-
owner->set_msg_handler([](const pmt_t& val) { this->operator(val); });
175+
owner->set_msg_handler([](const pmt_t& val) { this->operator()(val); });
173176
}
174177
175178
bool operator(const property_type& value) const
176179
{
177180
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);
179182
return false;
180183
}
181184
return true;
@@ -185,6 +188,7 @@ class sensitive_blk_impl : public sensitive_blk
185188
// int…
186189
// Most elegant would be to have a templated pmt_basic::to<target_type>()
187190
// operator?
191+
// Does pmtf solve this?
188192
/*
189193
bool operator(const pmt::pmt_t& polymorph) const
190194
{

0 commit comments

Comments
 (0)