pipe icon indicating copy to clipboard operation
pipe copied to clipboard

Number of elements in pipe

Open clivehaworth opened this issue 8 years ago • 1 comments

Hi, I'm trying to use pipe.c as the underlying mechanism for a Java InputStream in a JNI project.

All good - but I need a way to get the number of elements in the pipe at a specified time.

Is this possible?

clivehaworth avatar Oct 18 '17 20:10 clivehaworth

You can try add function like this:

size_t pipe_bytes(pipe_generic_t * p)
{
    return bytes_in_use(make_snapshot(p));   
}

and then get number of elements:

elements = pipe_bytes(p) / pipe_elem_size(p);

phryniszak avatar Feb 29 '20 23:02 phryniszak