ProteoWizard
Functions | Variables
COMInitializerTest.cpp File Reference
#include "Std.hpp"
#include "COMInitializer.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "boost/thread/thread.hpp"
#include "boost/thread/barrier.hpp"

Go to the source code of this file.

Functions

void testThreadSafetyWorker (boost::barrier *testBarrier)
void testThreadSafety ()
int main (int argc, char *argv[])

Variables

ostream * os_ = 0

Function Documentation

void testThreadSafetyWorker ( boost::barrier *  testBarrier)

Definition at line 36 of file COMInitializerTest.cpp.

References pwiz::util::COMInitializer::initialize(), pwiz::util::COMInitializer::uninitialize(), and unit_assert.

{
testBarrier->wait(); // wait until all threads have started
unit_assert(!COMInitializer::uninitialize());
unit_assert(COMInitializer::uninitialize());
}
void testThreadSafety ( )

Definition at line 46 of file COMInitializerTest.cpp.

References testThreadSafetyWorker().

{
const int testThreadCount = 100;
boost::barrier testBarrier(testThreadCount);
boost::thread_group testThreadGroup;
for (int i=0; i < testThreadCount; ++i)
testThreadGroup.add_thread(new boost::thread(&testThreadSafetyWorker, &testBarrier));
testThreadGroup.join_all();
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 57 of file COMInitializerTest.cpp.

References e(), os_, TEST_EPILOG, TEST_FAILED, TEST_PROLOG, and testThreadSafety().

{
TEST_PROLOG(argc, argv)
try
{
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
if (os_) *os_ << "COMInitializerTest\n";
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 33 of file COMInitializerTest.cpp.