src/cx/buffer.h

changeset 539
9cd98da9ee17
parent 537
16219eba3a0a
child 541
67e078518935
--- a/src/cx/buffer.h	Sat Apr 30 09:03:17 2022 +0200
+++ b/src/cx/buffer.h	Sat Apr 30 09:47:20 2022 +0200
@@ -91,6 +91,40 @@
     /** Current size of the buffer content. */
     size_t size;
     /**
+     * The buffer may not extend beyond this threshold before starting to flush.
+     * Default is \c SIZE_MAX (flushing disabled when auto extension is enabled).
+     */
+    size_t flush_threshold;
+    /**
+     * The block size for the elements to flush.
+     * Default is 4096 bytes.
+     */
+    size_t flush_blksize;
+    /**
+     * The maximum number of blocks to flush in one cycle.
+     * Zero disables flushing entirely (this is the default).
+     * Set this to \c SIZE_MAX to flush the entire buffer.
+     *
+     * @attention if the maximum number of blocks multiplied with the block size
+     * is smaller than the expected contents written to this buffer within one write
+     * operation, multiple flush cycles are performed after that write.
+     * That means the total number of blocks flushed after one write to this buffer may
+     * be larger than \c flush_blkmax.
+     */
+    size_t flush_blkmax;
+
+    /**
+     * The write function used for flushing.
+     * If NULL, the flushed content gets discarded.
+     */
+    size_t (*flush_func)(
+            void const *,
+            size_t,
+            size_t,
+            void *
+    );
+
+    /**
      * Flag register for buffer features.
      * @see #CX_BUFFER_DEFAULT
      * @see #CX_BUFFER_FREE_CONTENTS

mercurial