1 /*------------------------------------------------------------------------
2 Junction: Concurrent data structures in C++
3 Copyright (c) 2016 Jeff Preshing
5 Distributed under the Simplified BSD License.
6 Original location: https://github.com/preshing/junction
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the LICENSE file for more information.
11 ------------------------------------------------------------------------*/
13 #ifndef SAMPLES_MAPCORRECTNESSTESTS_TESTENVIRONMENT_H
14 #define SAMPLES_MAPCORRECTNESSTESTS_TESTENVIRONMENT_H
16 #include <junction/Core.h>
17 #include <turf/extra/JobDispatcher.h>
18 #include <turf/Trace.h>
19 #include <junction/extra/MapAdapter.h>
21 using namespace turf::intTypes;
22 typedef junction::extra::MapAdapter MapAdapter;
24 struct TestEnvironment {
25 turf::extra::JobDispatcher dispatcher;
28 std::vector<MapAdapter::ThreadContext> threads;
30 TestEnvironment() : numThreads(dispatcher.getNumPhysicalCores()), adapter(numThreads) {
31 TURF_ASSERT(numThreads > 0);
32 for (ureg t = 0; t < numThreads; t++)
33 threads.push_back(MapAdapter::ThreadContext(adapter, t));
34 dispatcher.kickMulti(&MapAdapter::ThreadContext::registerThread, &threads[0], threads.size());
38 dispatcher.kickMulti(&MapAdapter::ThreadContext::unregisterThread, &threads[0], threads.size());
42 #endif // SAMPLES_MAPCORRECTNESSTESTS_TESTENVIRONMENT_H