|
CX Framework
Cross-platform C utility framework
|
Functions | |
| StreamBuffer * | sbufCreate (size_t targetsz) |
| void | sbufRelease (StreamBuffer **sb) |
| void | sbufError (StreamBuffer *sb) |
| bool | sbufIsPull (StreamBuffer *sb) |
| bool | sbufIsPush (StreamBuffer *sb) |
| bool | sbufIsError (StreamBuffer *sb) |
| bool | sbufIsPFinished (StreamBuffer *sb) |
| bool | sbufIsCFinished (StreamBuffer *sb) |
Core stream buffer lifecycle and state management.
Operating Modes:
Push Mode: Producer repeatedly calls sbufPWrite(). Consumer is either notified that data is available via callback, or in direct mode, data is pushed immediately to the consumer's callback.
Pull Mode: Consumer repeatedly calls sbufCRead() or sbufCSend(). Producer's pull callback is invoked to fill the buffer as needed.
| StreamBuffer * sbufCreate | ( | size_t | targetsz | ) |
StreamBuffer *sbufCreate(size_t targetsz)
Creates a new stream buffer with the specified target size.
The buffer will automatically grow as needed but tries to stay near targetsz. Set targetsz to 0 only when using direct push mode (no buffering needed).
| targetsz | Target buffer size in bytes (0 for direct mode) |
Example:
| void sbufError | ( | StreamBuffer * | sb | ) |
void sbufError(StreamBuffer *sb)
Puts the stream buffer into error state.
Processing will be aborted and both producer and consumer should call their respective Finish functions as soon as practical.
| sb | The stream buffer |
|
inline |
bool sbufIsCFinished(StreamBuffer *sb)
Checks if the consumer is finished.
Returns true if consumer has exited early (no longer needs data to be produced).
| sb | The stream buffer |
Definition at line 234 of file streambuf.h.
References sbufIsError().
|
inline |
bool sbufIsError(StreamBuffer *sb)
Checks if the stream buffer is in an error state.
| sb | The stream buffer |
Definition at line 210 of file streambuf.h.
Referenced by sbufIsCFinished(), and sbufIsPFinished().
|
inline |
bool sbufIsPFinished(StreamBuffer *sb)
Checks if the producer is finished (EOF).
| sb | The stream buffer |
Definition at line 221 of file streambuf.h.
References sbufIsError().
|
inline |
bool sbufIsPull(StreamBuffer *sb)
Checks if the stream buffer is in pull mode.
| sb | The stream buffer |
Definition at line 188 of file streambuf.h.
|
inline |
bool sbufIsPush(StreamBuffer *sb)
Checks if the stream buffer is in push mode.
| sb | The stream buffer |
Definition at line 199 of file streambuf.h.
| void sbufRelease | ( | StreamBuffer ** | sb | ) |
void sbufRelease(StreamBuffer **sb)
Releases a reference to a stream buffer.
Decrements the reference count and destroys the buffer when it reaches zero. Sets the pointer to NULL after release.
| sb | Pointer to stream buffer pointer |