discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Message Strobe OOT block - problem with threads


From: isaac mario tupac davila
Subject: Re: Message Strobe OOT block - problem with threads
Date: Fri, 9 Jul 2021 12:35:18 -0500

Hi Marcus

I'm setting d_finished = true in the stop() function, like GNU Radio message strobe do it:

bool
    thread_ptr_impl::stop()
    {
       // Shut down the thread
      d_finished = true;
      d_thread->interrupt();
      d_thread->join();

      return block::stop();
    }

El vie, 9 jul 2021 a las 12:07, Marcus Müller (<mmueller@gnuradio.org>) escribió:
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.
>
>
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]