Page Speed Optimization Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | List of all members
net_instaweb::MockScheduler Class Reference

#include "mock_scheduler.h"

Inheritance diagram for net_instaweb::MockScheduler:

Public Member Functions

 MockScheduler (ThreadSystem *thread_system, MockTimer *timer)
virtual void RegisterWorker (QueuedWorkerPool::Sequence *w) LOCKS_EXCLUDED(mutex())
virtual void UnregisterWorker (QueuedWorkerPool::Sequence *w) LOCKS_EXCLUDED(mutex())
void AwaitQuiescence () LOCKS_EXCLUDED(mutex())
 Blocks until all work in registered workers is done.
void AdvanceTimeMs (int64 timeout_ms) LOCKS_EXCLUDED(mutex())
 Similar to BlockingTimedWaitUs but takes the lock for convenience.
void AdvanceTimeUs (int64 timeout_us) LOCKS_EXCLUDED(mutex())
void SetTimeUs (int64 time_us) LOCKS_EXCLUDED(mutex())
 Sets the current absolute time using absolute numbers.
- Public Member Functions inherited from net_instaweb::Scheduler
 Scheduler (ThreadSystem *thread_system, Timer *timer)
ThreadSystem::CondvarCapableMutexmutex () LOCK_RETURNED(mutex_)
void DCheckLocked () EXCLUSIVE_LOCKS_REQUIRED(mutex())
 Optionally check that mutex is locked for debugging purposes.
void BlockingTimedWaitMs (int64 timeout_ms) EXCLUSIVE_LOCKS_REQUIRED(mutex())
 Wait at most timeout_ms, or until Signal() is called. More...
void BlockingTimedWaitUs (int64 timeout_us) EXCLUSIVE_LOCKS_REQUIRED(mutex())
void TimedWaitMs (int64 timeout_ms, Function *callback) EXCLUSIVE_LOCKS_REQUIRED(mutex())
void Signal () EXCLUSIVE_LOCKS_REQUIRED(mutex())
Alarm * AddAlarmAtUs (int64 wakeup_time_us, Function *callback) LOCKS_EXCLUDED(mutex())
Alarm * AddAlarmAtUsMutexHeld (int64 wakeup_time_us, Function *callback) EXCLUSIVE_LOCKS_REQUIRED(mutex())
bool CancelAlarm (Alarm *alarm) EXCLUSIVE_LOCKS_REQUIRED(mutex())
bool ProcessAlarmsOrWaitUs (int64 timeout_us) EXCLUSIVE_LOCKS_REQUIRED(mutex())
Timertimer ()
ThreadSystemthread_system ()
 Obtain the thread system used by the scheduler.
void Wakeup ()
int64 RunAlarms (bool *ran_alarms) EXCLUSIVE_LOCKS_REQUIRED(mutex())
SequenceNewSequence ()
 Creates a new sequence, controlled by the scheduler.

Protected Member Functions

virtual void AwaitWakeupUntilUs (int64 wakeup_time_us) EXCLUSIVE_LOCKS_REQUIRED(mutex())
- Protected Member Functions inherited from net_instaweb::Scheduler
bool running_waiting_alarms () const

Detailed Description

Implements a Scheduler where time is virtualized, and TimedWait blocks the thread until mock-time is advanced.

The TimedWait implemention employs the worker's idle_callback to signal the underlying condition variable when the requested time has passed.

Member Function Documentation

virtual void net_instaweb::MockScheduler::AwaitWakeupUntilUs ( int64  wakeup_time_us)

Internal method to await a wakeup event. Block until wakeup_time_us (an absolute time since the epoch), or until something interesting (such as a call to Signal) occurs. This is virtual to permit us to mock it out (the mock simply advances time). This maybe called with 0 in case where there are no timers currently active.

Reimplemented from net_instaweb::Scheduler.

virtual void net_instaweb::MockScheduler::RegisterWorker ( QueuedWorkerPool::Sequence w)

These methods notify the scheduler of work sequences that may run work on it. They are only used for time simulations in MockScheduler and are no-ops during normal usage.

Reimplemented from net_instaweb::Scheduler.

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