gfx/skia/trunk/include/utils/SkCondVar.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2012 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef SkCondVar_DEFINED
michael@0 9 #define SkCondVar_DEFINED
michael@0 10
michael@0 11 #ifdef SK_USE_POSIX_THREADS
michael@0 12 #include <pthread.h>
michael@0 13 #elif defined(SK_BUILD_FOR_WIN32)
michael@0 14 #include <windows.h>
michael@0 15 #endif
michael@0 16
michael@0 17 /**
michael@0 18 * Condition variable for blocking access to shared data from other threads and
michael@0 19 * controlling which threads are awake.
michael@0 20 *
michael@0 21 * Currently only supported on platforms with posix threads and Windows Vista and
michael@0 22 * above.
michael@0 23 */
michael@0 24 class SkCondVar {
michael@0 25 public:
michael@0 26 SkCondVar();
michael@0 27 ~SkCondVar();
michael@0 28
michael@0 29 /**
michael@0 30 * Lock a mutex. Must be done before calling the other functions on this object.
michael@0 31 */
michael@0 32 void lock();
michael@0 33
michael@0 34 /**
michael@0 35 * Unlock the mutex.
michael@0 36 */
michael@0 37 void unlock();
michael@0 38
michael@0 39 /**
michael@0 40 * Pause the calling thread. Will be awoken when signal() or broadcast() is called.
michael@0 41 * Must be called while lock() is held (but gives it up while waiting). Once awoken,
michael@0 42 * the calling thread will hold the lock once again.
michael@0 43 */
michael@0 44 void wait();
michael@0 45
michael@0 46 /**
michael@0 47 * Wake one thread waiting on this condition. Must be called while lock()
michael@0 48 * is held.
michael@0 49 */
michael@0 50 void signal();
michael@0 51
michael@0 52 /**
michael@0 53 * Wake all threads waiting on this condition. Must be called while lock()
michael@0 54 * is held.
michael@0 55 */
michael@0 56 void broadcast();
michael@0 57
michael@0 58 private:
michael@0 59 #ifdef SK_USE_POSIX_THREADS
michael@0 60 pthread_mutex_t fMutex;
michael@0 61 pthread_cond_t fCond;
michael@0 62 #elif defined(SK_BUILD_FOR_WIN32)
michael@0 63 CRITICAL_SECTION fCriticalSection;
michael@0 64 CONDITION_VARIABLE fCondition;
michael@0 65 #endif
michael@0 66 };
michael@0 67
michael@0 68 #endif

mercurial