Gr-buffer - threadsafe?

Hi!

Can I assume gr_buffer + gr_buffer_reader to be thread-safe?

Regards
Dominik

Dominik A. wrote:

Can I assume gr_buffer + gr_buffer_reader to be thread-safe?

In the existing code, methods on these objects are only called by the
runtime scheduler from within a single thread, so there is no need for
thread safety.

The buffers between GNU Radio blocks are internal implementation details
that user code never needs to deal with, and might change arbitrarily.
What is it you’re trying to accomplish?


Johnathan C.
Corgan Enterprises LLC
http://corganenterprises.com

On Fri, Mar 02, 2007 at 02:22:50PM +0100, Dominik A. wrote:

Hi!

Can I assume gr_buffer + gr_buffer_reader to be thread-safe?

Regards
Dominik

Hi Dominik,

It should be fine, though I don’t think it’s been tested in a
multi-threaded environment. It’s single writer, multiple-reader, and
each piece of state has only a single modifier. It’s basically a
variant on the standard lock-free ring buffer. On non-x86 machine
SMP machines (e.g. PPC) it may require the addition of memory barriers.

Eric

Hi!

I am designing a block, owning an inner object, and now both will need a
communication way. Since it’s just one way, your buffer fulfills all my
need.

Do you think I should use a synchronisation object (e.g. mutex)?

The inner object could possibly have an own event processing loop, i.e.
can
be a separate thread, and the outer block will be in a flow graph.

I know that they are implementation details, but I thought it’s better
to
reuse them instead of writing a new implementation.

Dominik