On Sat, Jul 15, 2017 at 11:33 AM, Vamsi Krishna Adsumilli <
vamsi...@yahoo.com> 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.
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to