# Gr\_sync\_block question

**URL:** <https://www.ruby-forum.com/t/gr-sync-block-question/218411>\
**Category:** GNU Radio\
**Created:** [March 30, 2012, 8:24pm UTC](https://www.ruby-forum.com/t/gr-sync-block-question/218411 "2012-03-30T20:24:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 30, 2012, 8:24pm UTC](https://www.ruby-forum.com/t/gr-sync-block-question/218411/1 "2012-03-30T20:24:25Z")

</div>

Do objects that extend gr\_sync\_block _require_ that their work function  
_always_ returns as many items as the scheduler asked in noutput\_items,  
except for the case when a block may be completely finished producing  
items? What does the scheduler do if the (number of items returned) \<  
noutput\_items? Does it ever try calling the work function again?

Thanks,  
Sean

---

<div class="post-metadata">

**Author:** ![NowlanS\_Sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f05b48/32.png) [@NowlanS\_Sean](https://www.ruby-forum.com/u/NowlanS_Sean)\
**Post date:** [March 30, 2012, 8:59pm UTC](https://www.ruby-forum.com/t/gr-sync-block-question/218411/2 "2012-03-30T20:59:24Z")

</div>

On 03/30/2012 11:23 AM, Nowlan, Sean wrote:

> Do objects that extend gr\_sync\_block _require_ that their work  
> function _always_ returns as many items as the scheduler asked in  
> noutput\_items, except for the case when a block may be completely  
> finished producing items? What does the scheduler do if the (number  
> of items returned) \< noutput\_items? Does it ever try calling the work  
> function again?

You can return any number of items between 1 and noutput\_items. The  
scheduler will simply call work again with any items that werent  
consumed + extra that accumulated into the input buffers in the interim  
time.

Returning 0 or -1 will tell the block executor code to stop.

-Josh

---

<div class="post-metadata">

**Author:** ![NowlanS\_Sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f05b48/32.png) [@NowlanS\_Sean](https://www.ruby-forum.com/u/NowlanS_Sean)\
**Post date:** [March 31, 2012, 4:53pm UTC](https://www.ruby-forum.com/t/gr-sync-block-question/218411/3 "2012-03-31T16:53:24Z")

</div>

On Fri, Mar 30, 2012 at 2:58 PM, Josh B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You can return any number of items between 1 and noutput\_items. The  
> scheduler will simply call work again with any items that werent  
> consumed + extra that accumulated into the input buffers in the interim  
> time.
> 
> Returning 0 or -1 will tell the block executor code to stop.
> 
> -Josh

Just to clarify, a block can legitimately return 0; it just means that  
it didn’t produce any output, but it will try again.

A -1 will cause this block to stop. If the block is a source and it  
produces -1, it will stop the flowgraph completely.

Tom

---

<div class="post-metadata">

**Author:** ![NowlanS\_Sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f05b48/32.png) [@NowlanS\_Sean](https://www.ruby-forum.com/u/NowlanS_Sean)\
**Post date:** [March 31, 2012, 7:29pm UTC](https://www.ruby-forum.com/t/gr-sync-block-question/218411/4 "2012-03-31T19:29:00Z")

</div>

On Sat, Mar 31, 2012 at 07:52, Tom R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Fri, Mar 30, 2012 at 2:58 PM, Josh B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > On 03/30/2012 11:23 AM, Nowlan, Sean wrote:

> it didn’t produce any output, but it will try again.  
> To clarify even further–a _source_ block that returns 0 samples will  
> be treated as done, for other blocks it is ok.

Johnathan

---

<div class="post-metadata">

**Author:** ![NowlanS\_Sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f05b48/32.png) [@NowlanS\_Sean](https://www.ruby-forum.com/u/NowlanS_Sean)\
**Post date:** [April 2, 2012, 4:26pm UTC](https://www.ruby-forum.com/t/gr-sync-block-question/218411/5 "2012-04-02T16:26:00Z")

</div>

Thanks for clearing that up. That’s what I surmised after poking around  
gr\_block\_executor; the problem turned out to be a mistake in the work  
function of a data source I put together.
