# Timers

**URL:** <https://www.ruby-forum.com/t/timers/161277>\
**Category:** GNU Radio\
**Created:** [February 24, 2009, 11:58pm UTC](https://www.ruby-forum.com/t/timers/161277 "2009-02-24T23:58:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcus\_DSLeech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/74df32/32.png) [@Marcus\_DSLeech](https://www.ruby-forum.com/u/Marcus_DSLeech)\
**Post date:** [February 24, 2009, 11:58pm UTC](https://www.ruby-forum.com/t/timers/161277/1 "2009-02-24T23:58:48Z")

</div>

What’s the best way to setup a timer routine that has access to the bits  
of the flowgraph?

I’m using an external process (UI) to set dynamic values for certain  
USRP attributes, and one of the mechanisms  
I’m thinking of using is to trigger a regular timer to see if the  
values in an external control file have changed, and if  
so, update the USRP settings.

I know that there’s gr\_local\_signal\_sighandler()–does the handler  
function have access to the flowgraph?

–  
Marcus L.  
Principal Investigator, Shirleys Bay Radio Astronomy Consortium

> **[Live Draw HK Tercepat | Result HK | HK Pools | Live HK | HK Prize Hari Ini](https://www.sbrac.org/)**
>
> Temukan live draw hk tercepat melalui halaman hk pools yang resmi dan dapatkan result hk prize melalui live hk secara langsung di situs kami.

---

<div class="post-metadata">

**Author:** ![Marcus\_DSLeech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/74df32/32.png) [@Marcus\_DSLeech](https://www.ruby-forum.com/u/Marcus_DSLeech)\
**Post date:** [February 25, 2009, 1:17am UTC](https://www.ruby-forum.com/t/timers/161277/2 "2009-02-25T01:17:53Z")

</div>

On Tue, Feb 24, 2009 at 05:57:35PM -0500, Marcus D. Leech wrote:

> function have access to the flowgraph?  
> No. In general it’s virtually impossible to safely uses threads and  
> signals together. If you need a timer, one way to get it is to use a  
> dedicated thread that manages the timer queue, then send messages to  
> those who want them when the timer expires.

[I’ll be implementing something like this in the next few months]

Eric

---

<div class="post-metadata">

**Author:** ![Marcus\_DSLeech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/74df32/32.png) [@Marcus\_DSLeech](https://www.ruby-forum.com/u/Marcus_DSLeech)\
**Post date:** [February 25, 2009, 3:04pm UTC](https://www.ruby-forum.com/t/timers/161277/3 "2009-02-25T15:04:44Z")

</div>

Eric B. wrote:

> No. In general it’s virtually impossible to safely uses threads and  
> signals together. If you need a timer, one way to get it is to use a  
> dedicated thread that manages the timer queue, then send messages to  
> those who want them when the timer expires.
> 
> [I’ll be implementing something like this in the next few months]
> 
> Eric

Actually, it turned out to be remarkably easy. With gr-generated code,  
the main program is just:

```
    topblock.start()
    raw_input()
    topbloack.stop()

```

Which means that main runs in a separate thread. So, I simply replaced  
raw\_input() with a loop that goes to  
sleep for 250msec, then checks the control file, then goes to sleep  
again. A bit in the control file asks the  
Python flowgraph to exit. Simple.

Wish there was an easy way to merge grc-generated code with stuff like  
this.

–  
Marcus L.  
Principal Investigator, Shirleys Bay Radio Astronomy Consortium

> **[Live Draw HK Tercepat | Result HK | HK Pools | Live HK | HK Prize Hari Ini](https://www.sbrac.org)**
>
> Temukan live draw hk tercepat melalui halaman hk pools yang resmi dan dapatkan result hk prize melalui live hk secara langsung di situs kami.
