Skip to content

Commit 93e45e6

Browse files
gezalorerfuest
andauthored
Add fstWriterGetFlushContextPending to writer API. (#8)
* Add fstWriterGetFlushContextPending to writer API. This is useful for coordinating compression between multiple writer instances in parallel. * Apply suggestions from code review Co-authored-by: Ralf Fuest <[email protected]> --------- Co-authored-by: Ralf Fuest <[email protected]>
1 parent 8d76056 commit 93e45e6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/fstapi.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -2536,6 +2536,17 @@ int fstWriterGetFseekFailed(void *ctx)
25362536
return (0);
25372537
}
25382538

2539+
static int fstWriterGetFlushContextPendingInternal(struct fstWriterContext *xc)
2540+
{
2541+
return (xc->vchg_siz >= xc->fst_break_size) || (xc->flush_context_pending);
2542+
}
2543+
2544+
int fstWriterGetFlushContextPending(void *ctx)
2545+
{
2546+
struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
2547+
return xc && !xc->is_initial_time && fstWriterGetFlushContextPendingInternal(xc);
2548+
}
2549+
25392550
/*
25402551
* writer attr/scope/var creation:
25412552
* fstWriterCreateVar2() is used to dump VHDL or other languages, but the
@@ -3161,7 +3172,7 @@ void fstWriterEmitTimeChange(void *ctx, uint64_t tim)
31613172
}
31623173
xc->is_initial_time = 0;
31633174
} else {
3164-
if ((xc->vchg_siz >= xc->fst_break_size) || (xc->flush_context_pending)) {
3175+
if (fstWriterGetFlushContextPendingInternal(xc)) {
31653176
xc->flush_context_pending = 0;
31663177
fstWriterFlushContextPrivate(xc);
31673178
xc->tchn_cnt++;

src/fstapi.h

+1
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ void fstWriterEmitTimeChange(void *ctx, uint64_t tim);
420420
void fstWriterFlushContext(void *ctx);
421421
int fstWriterGetDumpSizeLimitReached(void *ctx);
422422
int fstWriterGetFseekFailed(void *ctx);
423+
int fstWriterGetFlushContextPending(void *ctx);
423424
void fstWriterSetAttrBegin(void *ctx,
424425
enum fstAttrType attrtype,
425426
int subtype,

0 commit comments

Comments
 (0)