1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//******************************************************************** 383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius// Copyright (C) 2002-2011, International Business Machines 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// Corporation and others. All Rights Reserved. 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//******************************************************************** 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// File threadtest.h 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef ABSTRACTTHREADTEST_H 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define ABSTRACTTHREADTEST_H 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//------------------------------------------------------------------------------ 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// class AbstractThreadTest Base class for threading tests. 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// Use of this abstract base isolates the part of the 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// program that nows how to spin up and control threads 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// from the specific stuff being tested, and (hopefully) 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// simplifies adding new threading tests for different parts 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// of ICU. 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// Derived classes: A running test will have exactly one instance of a 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// derived class, which will persist for the duration of the 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// test and be shared among all of the threads involved in 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// the test. 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// The constructor will be called in a single-threaded environment, 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// and should set up any data that will need to persist for the 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// duration. 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// runOnce() will be called repeatedly by the working threads of 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// the test in the full multi-threaded environment. 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// check() will be called periodically in a single threaded 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// environment, with the worker threads temporarily suspended between 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// between calls to runOnce(). Do consistency checks here. 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//------------------------------------------------------------------------------ 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass AbstractThreadTest { 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru AbstractThreadTest() {}; 4083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius virtual ~AbstractThreadTest(); 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void check() = 0; 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void runOnce() = 0; 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif // ABSTRACTTHREADTEST_H 46