Skip to content

Commit

Permalink
swift: flush writer buffer when closing a chunk (#960)
Browse files Browse the repository at this point in the history
### Public-Facing Changes

Swift: data is now properly sent to the writer each time a chunk is
closed.

### Description
  • Loading branch information
jtbandes authored Aug 30, 2023
1 parent 23ff712 commit a68c769
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions swift/mcap/MCAPWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ public final class MCAPWriter {
}
} else {
message.serialize(to: &buffer)
if buffer.count >= options.chunkSize {
await _flush()
}
}
}

Expand Down Expand Up @@ -219,6 +222,7 @@ public final class MCAPWriter {

let chunkStartOffset = _position()
chunk.serialize(to: &buffer)
await _flush()
let messageIndexStartOffset = _position()

var messageIndexOffsets: [ChannelID: UInt64] = [:]
Expand Down

0 comments on commit a68c769

Please sign in to comment.