Page Speed Optimization Libraries  1.8.31.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions
net_instaweb::RewriteOptions::MutexedOptionInt64MergeWithMax Class Reference

#include "rewrite_options.h"

Inheritance diagram for net_instaweb::RewriteOptions::MutexedOptionInt64MergeWithMax:
net_instaweb::RewriteOptions::Option< int64 > net_instaweb::RewriteOptions::OptionTemplateBase< int64 > net_instaweb::RewriteOptions::OptionBase

List of all members.

Public Member Functions

virtual void Merge (const OptionBase *src_base)
void Merge (const MutexedOptionInt64MergeWithMax *src) LOCKS_EXCLUDED(src->mutex())
void checked_set (const int64 &value) EXCLUSIVE_LOCKS_REQUIRED(mutex())
ThreadSystem::RWLock * mutex () const LOCK_RETURNED(mutex_)
void set_mutex (ThreadSystem::RWLock *lock)

Detailed Description

Like Option<int64>, but merge by taking the Max of the two values. Note that this could be templatized on type in which case we'd need to inline the implementation of Merge.

This class has an optional mutex for allowing Apache to flush cache by mutating its global_options(). Note that global_options() is never used directly in a rewrite_driver, but is cloned with this optional Mutex held.

The "optional" mutex is always present, but it defaults to a NullRWLock, which has empty implementations of all locking/unlocking functions. Only in Apache (currently) do we override that with a real RWLock from the thread system.


Member Function Documentation

The value() must only be taken when the mutex is held. This is only called by RewriteOptions::UpdateCacheInvalidationTimestampMs and MutexedOptionInt64MergeWithMax::Merge, which are holding locks when calling value().

Note that we don't require or take the lock for set(), so we don't override set. When updating or merging, we already have a lock and can't take it again. When writing the invalidation timestamp at initial configuration time, we don't need the lock.

Merges src_base into this by taking the maximum of the two values.

We expect to have exclusive access to 'this' and don't need to lock it, but we use locked access to src_base->value().

Reimplemented from net_instaweb::RewriteOptions::OptionTemplateBase< int64 >.

We provide a more specific Merge here so that we can use an unaliased name for src to provide lock annotation.

Returns the mutex for this object. When this class is constructed it gets a NullRWLock which doesn't actually lock anything. This is because we generally initialize RewriteOptions from only one thread, and thereafter do only reads. However, one exception is the cache-invalidation timestamp in the global_options for Apache ServerContexts, which can be written from any thread handling a request, particularly with the Worker MPM. So we install a real RWLock* for Apache's global_options.

Also note that this mutex, when installed, is also used to lock access to RewriteOptions::signature(), which depends on the cache invalidation timestamp.

void net_instaweb::RewriteOptions::MutexedOptionInt64MergeWithMax::set_mutex ( ThreadSystem::RWLock *  lock) [inline]

Takes ownership of mutex. Note that by default, mutex() has a NullRWLock. Only by calling set_mutex do we add locking semantics for the invalidation timestamp & signature. If we allow other settings to be spontaneously changed we will have to add further locking.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines