Beispiel #1
0
    bool test(int threadCount, int iterationCount) {
        m_iterationCount = iterationCount;
        for (int j = 0; j < SharedArraySize; j++)
            m_shared[j] = j;
        m_success.storeNonatomic(1);

        // FIXME: Make this use turf::extra::JobDispatcher so that the starts are better synchronized.
        std::vector<std::thread> threads;
        for (int i = 0; i < threadCount; i++)
            threads.emplace_back(&RWLockTester::threadFunc, this, i);
        for (std::thread& t : threads)
            t.join();

        return m_success.loadNonatomic() != 0;
    }
 SharedState(MapAdapter& adapter, ureg numThreads, ureg numKeysPerThread, ureg readsPerWrite, ureg itersPerChunk)
     : adapter(adapter), map(NULL), numKeysPerThread(numKeysPerThread), numThreads(numThreads), readsPerWrite(readsPerWrite), itersPerChunk(itersPerChunk) {
     delayFactor = 0.5f;
     doneFlag.storeNonatomic(0);
 }