xant/libhl

Is there any document to introduce the APIs?

Closed this issue · 2 comments

About how to use the opened APIs and the meaning of the return value.

For example , if the mode of rqueue is RQUEUE_MODE_OVERWRITE, how do I know the ring is overwritten from the return value? And whether the operation is written successfully.

xant commented

The documentation is what you have in the headers.
The return value in rbuf_write() indicates how many bytes have been written and let you detect if the ringbuffer is full when RBUF_MODE_BLOCKING.
In case of RBUF_MODE_OVERWRITE you don't have any indication that the overwrite occurred but the write will always succeed for the whole input buffer.
Obviously you can look at the value returned rbuf_available() before writing so you know if your write is going to overflow the ringbuffer (and cause overwrites) or not.

Feel free to open a pull request if you have any improvement to the headerdoc