[haiku-3rdparty-dev] BBuffer expected lifecycle

  • From: Barrett <b.vitruvio@xxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Fri, 27 Dec 2013 12:02:04 +0100

I have a BBufferConsumer (which for simplicity i'll call thread A), and i
have to post-pone the handling of buffers to a thread B in an
'asynchronous' fashion. Basically i want to keep the minimum latency in the
BufferReceived() function and give the work to a background (and less
priority) thread.

The first attack plan that come to my mind is to create a FIFO, copy those
buffers into this object (with locking) and continue. On the other hand the
thread B will wait for the FIFO to be filled and when the condition happen,
will do something with those buffers, which may be for example just coping
them in a container class or writing up to the disk.

My question is, to avoid the copy of buffers in the FIFO, could i let the
BBuffers to come to this thread B adding this BBuffer to the fifo directly,
without blocking the MediaNode thread in any way?

My idea is to call Recycle() when the thread B is done with the buffer, so
that it will be returned to the BBufferGroup and reused for future
computations.

Is this supposed to be a good pratice in media_kit programming?

I'm trying to achieve the max from this node, i've to admit i've not tried
it already just because i'm already thinking of it.

Best Regards

Other related posts: