MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / test

Method test

extern/libcds/test/stress/queue/random.cpp:56–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54 }
55
56 virtual void test()
57 {
58 size_t const nThreadCount = s_nThreadCount;
59 size_t const nTotalPush = m_nTotalPushCount;
60
61 m_arrLastRead.resize( nThreadCount, 0 );
62 m_arrPopCountPerThread.resize( nThreadCount, 0 );
63
64 value_type node;
65
66 while ( m_nPushCount < nTotalPush ) {
67 if ( ( std::rand() & 3) != 3 ) {
68 node.nThread = id();
69 node.nNo = ++m_nPushCount;
70 if ( !m_Queue.push( node )) {
71 ++m_nPushError;
72 --m_nPushCount;
73 }
74 }
75 else
76 pop( nThreadCount );
77 }
78
79 s_nProducerCount.fetch_sub( 1, std::memory_order_relaxed );
80
81 while ( !m_Queue.empty() || s_nProducerCount.load( std::memory_order_relaxed ) != 0 )
82 pop( nThreadCount );
83 }
84
85 bool pop( size_t nThreadCount )
86 {

Callers

nothing calls this directly

Calls 7

idFunction · 0.50
popFunction · 0.50
resizeMethod · 0.45
pushMethod · 0.45
fetch_subMethod · 0.45
emptyMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected