MCPcopy Create free account
hub / github.com/apache/arrow / StressTaskGroupLifetime

Function StressTaskGroupLifetime

cpp/src/arrow/util/task_group_test.cc:234–255  ·  view source on GitHub ↗

Try to replicate subtle lifetime issues when destroying a TaskGroup where all tasks may not have finished running.

Source from the content-addressed store, hash-verified

232// Try to replicate subtle lifetime issues when destroying a TaskGroup
233// where all tasks may not have finished running.
234void StressTaskGroupLifetime(std::function<std::shared_ptr<TaskGroup>()> factory) {
235 const int NTASKS = 100;
236 auto task_group = factory();
237 auto weak_group_ptr = std::weak_ptr<TaskGroup>(task_group);
238
239 std::atomic<bool> barrier(false);
240
241 BarrierTask task{&barrier, weak_group_ptr, Status::OK()};
242
243 for (int i = 0; i < NTASKS; ++i) {
244 task_group->Append(task);
245 }
246
247 // Lose strong reference
248 barrier.store(true);
249 task_group.reset();
250
251 // Wait for finish
252 while (!weak_group_ptr.expired()) {
253 SleepFor(1e-5);
254 }
255}
256
257// Same, but with also a failing task
258void StressFailingTaskGroupLifetime(std::function<std::shared_ptr<TaskGroup>()> factory) {

Callers 1

TESTFunction · 0.85

Calls 6

factoryFunction · 0.85
SleepForFunction · 0.85
storeMethod · 0.80
OKFunction · 0.50
AppendMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected