Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
net_instaweb::CondvarTestBase Class Referenceabstract
Inheritance diagram for net_instaweb::CondvarTestBase:

Protected Types

typedef void(ThreadSystem::Condvar::* SignalMethod )()
 

Protected Member Functions

void Init (ThreadSystem::CondvarCapableMutex *mutex, ThreadSystem::Condvar *startup_condvar, ThreadSystem::Condvar *condvar)
 
virtual void CreateHelper ()=0
 
virtual void FinishHelper ()=0
 
void StartHelper ()
 
virtual void HelperThreadMethod ()
 
void StartupTest ()
 Below are the common tests that should be run by every client. More...
 
void BlindSignalsTest ()
 
void PingPongTest ()
 
void TimeoutTest ()
 Make sure that TimedWait eventually progresses in the absence of a signal. More...
 
void LongTimeoutTest (int wait_ms)
 Make sure that a long timeout doesn't exit too early. More...
 
void TimeoutPingPongTest ()
 
virtual Timertimer ()=0
 

Static Protected Member Functions

static void * HelperThread (void *data)
 

Protected Attributes

ThreadSystem::CondvarCapableMutexmutex_
 
ThreadSystem::Condvarstartup_condvar_
 
ThreadSystem::Condvarcondvar_
 
bool ready_to_start_
 
int iters_
 
int current_iter_
 
SignalMethod signal_method_
 
bool wait_after_signal_
 
int helper_increments_
 
bool init_called_
 

Member Function Documentation

void net_instaweb::CondvarTestBase::BlindSignalsTest ( )
inlineprotected

Run the helper without interacting with it. Also run with signal_method_ = &ThreadSystem::Condvar::Broadcast

virtual void net_instaweb::CondvarTestBase::CreateHelper ( )
protectedpure virtual

CreateHelper creates a thread that ultimately calls this->HelperThreadMethod(), most simply by invoking HelperThread(this). It runs this method to completion, and then terminates gracefully.

virtual void net_instaweb::CondvarTestBase::FinishHelper ( )
protectedpure virtual

FinishHelper is called in the main thread to wait for graceful termination of the thread created by CreateHelper.

virtual void net_instaweb::CondvarTestBase::HelperThreadMethod ( )
inlineprotectedvirtual

We must hold the mutex to access the iteration count and check the loop condition.

void net_instaweb::CondvarTestBase::Init ( ThreadSystem::CondvarCapableMutex mutex,
ThreadSystem::Condvar startup_condvar,
ThreadSystem::Condvar condvar 
)
inlineprotected

Init is intended to be called from the constructor of the derived class. Ownership of the objects remains with the caller.

void net_instaweb::CondvarTestBase::LongTimeoutTest ( int  wait_ms)
inlineprotected

Make sure that a long timeout doesn't exit too early.

This test should not be flaky even if it runs slowly, as we are not placing an upper bound on the lock duration.

void net_instaweb::CondvarTestBase::PingPongTest ( )
inlineprotected

Use condvars to pass control back and forth between worker and main thread. Also run with signal_method_ = &ThreadSystem::Condvar::Broadcast

We must hold the mutex to access the iteration count and check the loop condition.

void net_instaweb::CondvarTestBase::StartupTest ( )
inlineprotected

Below are the common tests that should be run by every client.

Make sure we can start and stop the helper gracefully.

void net_instaweb::CondvarTestBase::TimeoutPingPongTest ( )
inlineprotected

Use condvars to pass control back and forth between worker and main thread. Final interaction will be one-sided and will time out. Also run with signal_method_ = &ThreadSystem::Condvar::Broadcast

We must hold the mutex to access the iteration count and check the loop condition. Note that in case of timeout we might get here with current_iter_ % 2 == 0, so we might perform more local increments than we expect.

void net_instaweb::CondvarTestBase::TimeoutTest ( )
inlineprotected

Make sure that TimedWait eventually progresses in the absence of a signal.

< This will deadlock if we don't time out.


The documentation for this class was generated from the following file: