35 auto const flowId =
"5fbec3b1-1b0f-417d-9059-8b94a47197ed";
55 auto const grainCount =
static_cast<std::uint64_t
>(
configInfo.discrete.grainCount);
58 REQUIRE(headIndex > grainCount);
61 auto tailIndex = headIndex - grainCount + 1;
62 for (
auto i = std::uint64_t{0}; i < grainCount; ++i)
65 std::uint8_t*
buffer =
nullptr;
70 buffer[grainInfo.grainSize - 1] = 0xFE;
71 grainInfo.validSlices = grainInfo.totalSlices;
82 REQUIRE(runtimeInfo.headIndex == headIndex);
87 std::uint8_t* readBuffer =
nullptr;
90 INFO(
"The tailIndex grain read should return TOO_LATE even when no write "
91 "is in progress because the tail grain is reserved for the writer.");
102 INFO(
"The tailIndex slice read should return TOO_LATE even when no write "
103 "is in progress because the tail grain is reserved for the writer.");
110 std::uint8_t* writeBuffer =
nullptr;
114 INFO(
"The newly opened grain should identify headIndex+1.");
115 CAPTURE(writeGrainInfo.index, headIndex + 1, writeGrainInfo.validSlices, writeGrainInfo.totalSlices);
116 CHECK(writeGrainInfo.index == headIndex + 1);
121 REQUIRE(runtimeInfo.headIndex == headIndex);
126 constexpr auto NOT_CHANGED_INDEX_SENTINEL_VALUE = std::numeric_limits<
decltype(readGrainInfo.index)>::max();
127 readBuffer =
nullptr;
129 readGrainInfo.index = NOT_CHANGED_INDEX_SENTINEL_VALUE;
132 INFO(
"A tailIndex read should return TOO_LATE while a write of "
133 "headIndex+1 is open because both logical grains alias the "
134 "same physical ring-buffer position."
140 INFO(
"Because the tailIndex grain read is expected to return TOO_LATE, "
141 "it should not return a payload or modify the grain index.");
142 CHECK(readBuffer ==
nullptr);
143 CHECK(readGrainInfo.index == NOT_CHANGED_INDEX_SENTINEL_VALUE);
149 constexpr auto NOT_CHANGED_SLICE_SENTINEL_VALUE = std::numeric_limits<
decltype(readGrainInfo.validSlices)>::max();
150 readBuffer =
nullptr;
152 readGrainInfo.validSlices = NOT_CHANGED_SLICE_SENTINEL_VALUE;
155 INFO(
"A tailIndex slice read should return TOO_LATE while a write of "
156 "headIndex+1 is open because both logical grains alias the "
157 "same physical ring-buffer position.");
161 INFO(
"Because the tailIndex slice read is expected to return TOO_LATE, "
162 "it should not return a payload or modify validSlices.");
163 CHECK(readBuffer ==
nullptr);
164 CHECK(readGrainInfo.validSlices == NOT_CHANGED_SLICE_SENTINEL_VALUE);
168 writeBuffer[0] = 0xCA;
169 writeBuffer[writeGrainInfo.grainSize - 1] = 0xFE;
170 writeGrainInfo.validSlices = writeGrainInfo.totalSlices;
173 headIndex = headIndex + 1;
174 tailIndex = headIndex - grainCount + 1;
178 REQUIRE(runtimeInfo.headIndex == headIndex);
182 readBuffer =
nullptr;
186 INFO(
"A post commit tailIndex read should return TOO_LATE after a "
187 "write of headIndex+1 is committed because both logical grains "
188 "alias the same physical ring-buffer position.");
224 auto const flowId =
"b3bb5be7-9fe9-4324-a5bb-4c70e1084449";
244 auto const bufferLength =
static_cast<std::uint64_t
>(
configInfo.continuous.bufferLength);
245 auto const halfBufferLength = bufferLength / 2U;
247 REQUIRE(halfBufferLength > 0U);
248 REQUIRE(headIndex > bufferLength);
254 auto const boundaryIndex = headIndex - halfBufferLength + 1;
255 auto tmpWriteIndex = boundaryIndex - 1;
256 for (
auto i = std::uint64_t{0}; i < 2U; ++i)
264 tmpWriteIndex += halfBufferLength;
274 REQUIRE(runtimeInfo.headIndex == headIndex);
278 auto const boundaryIndex = headIndex - halfBufferLength + 1;
279 auto const ringTailIndex = headIndex - bufferLength + 1;
298 REQUIRE(runtimeInfo.headIndex == headIndex);
317 headIndex = headIndex + halfBufferLength;
322 REQUIRE(runtimeInfo.headIndex == headIndex);
325 auto const newBoundaryIndex = headIndex - halfBufferLength + 1;
MXL_EXPORT mxlStatus mxlCreateFlowWriter(mxlInstance instance, char const *flowDef, char const *options, mxlFlowWriter *writer, mxlFlowConfigInfo *configInfo, bool *created)