google / google/benchmark

[FR] Share objects between threads

Open
#1,003 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
10.4k
Forks
1.8k
Avg merge
2d 4h
Merged PRs (30d)
8

Description

Data-parallel multithreaded code normally operates over shared objects (e.g. arrays).
Currently I don't see a nice way to share objects between threads so, that those objects can be gracefully constructed and destructed.
I'd like to see an enhanced RunBenchmark:
```
RunResults RunBenchmark(
const benchmark::internal::BenchmarkInstance& b,
std::vector* complexity_reports) {
b.benchmark->StartRunning();
internal::BenchmarkRunner r(b, complexity_reports);
b.benchmark->FinishRunning();
return r.get_results();
}
```
StartRunning and FinishRunning are newly introduced virtual functions, which would solve my problem, since the benchmark object itself is shared and inside that functions I can create and destroy the object.

See also https://groups.google.com/g/benchmark-discuss/c/VnfCTsfLy2s
which didn't point to any alternative solution.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.