discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Block Method called at end of Simulation


From: Kevin Reid
Subject: Re: [Discuss-gnuradio] Block Method called at end of Simulation
Date: Sat, 15 Jul 2017 13:15:02 -0700

On Sat, Jul 15, 2017 at 11:33 AM, Vamsi Krishna Adsumilli <address@hidden> wrote:
Is there a method (API) in each block which is being called when flow graph is ended (simulation stopped), to clean up resources like closing files, disconnecting database or killing threads.

tb.stop()

I have an OOT module in which timer is being called on separate thread, when the flow graph is ended I would like to kill the thread.

You could override stop() (and start()) in your block class — they will be called on each block when the top block is started or stopped.

However, this is not the right time to clean up resources permanently, because in general the flow graph may be started again (either because of an explicit tb.start(), or because of a lock()/reconfigure/unlock()). It should only be used for harmless/reversible actions such as telling hardware to stop sending/expecting data or flushing IO.

Instead, clean up in your block's destructor. This is the only time it is guaranteed that your block won't be used again.

Examples of such actions in either stop() or the destructor can be found mostly in source and sink blocks since those are the ones which most often interact with external resources.


reply via email to

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