[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Message Strobe OOT block - problem with threads
From: |
Marcus Müller |
Subject: |
Re: Message Strobe OOT block - problem with threads |
Date: |
Fri, 9 Jul 2021 19:07:35 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
Hi Isaac,
where do you set `d_finished = true;`?
On 09.07.21 19:04, isaac mario tupac davila wrote:
> Hello
>
> My name is Isaac . I'm trying to do a message strobe OOT block which could
> read a .txt
> file to define a list of command messages. I created a general block and
> deleted the
> general_work class as messages work in a separate thread.
>
> I literally write the same idea of the message strobe block provided by GNU
> Radio for
> the use of the thread:
>
> bool
> thread_ptr_impl::start()
> {
> // NOTE: d_finished should be something explicitly thread safe. But
> since
> // nothing breaks on concurrent access, I'll just leave it as bool.
> d_finished = false;
> d_thread = boost::shared_ptr<gr::thread::thread>
> (new gr::thread::thread(boost::bind(&thread_ptr_impl::run, this)));
> return block::start();
> }
>
> void thread_ptr_impl::run()
> {
> while(!d_finished) {
>
> boost::this_thread::sleep(boost::posix_time::milliseconds(static_cast<long>(d_period_ms)));
> if(d_finished) {
> return;
> }
> message_port_pub(d_port, d_msg);
> }
> }
>
> My problem is that when GNU Radio finishes to wait in the run() function
> (boost::this_thread::sleep) , instead of continuing with the conditional
> "if", it
> finishes the programme and it doesn't achieve publish the message.
>
> ¿What could be happening here? ¿Why is this happening here and doesn't happen
> in the GNU
> Radio message strobe? ¿Maybe a configuration in the CMake or I have to choose
> a
> non-general OOT block?
>
> I really appreciate any idea or suggestion.
> Thanks
> Isaac T.
>
>
>
>