category |
class |
Description |
Example |
Threading mechanism |
Thread |
(Reference: Threading model and Application Guide)
|
|
Messagepump |
|
MessageQueue |
|
Sequencedworkerpool |
It is a thread pool for performing task requests that need to be executed serially, based on different token groupings, guaranteeing the order of execution only within the same group. This allows multiple groups to execute in parallel, while a single group executes serially. For example: different instances of the corresponding grouping, or different functions corresponding to different groups. It also allows you to specify how tasks that are not performed when exiting are handled, including: Continue, ignore, block exit. Reference: The FILE thread is dead, long live the blocking pool. |
|
concurrency control mechanism |
Volatile |
Language is based on the features provided by the processor. Ensure that each thread reads the data at the most recent value. But the use of it needs to master a certain skill. Reference: Depth profiling of C/C + + volatile keywords |
|
|
Atomic32 (BASE/ATOMICOPS.H) Atomicsequencenumber (base/atomic_sequence_num.h) Atomicrefcountxxx (base/atomic_ref_count.h) |
The atomic data type provided by the chromium. |
|
|
Autolock Autounlock Lock (base/synchronization/lock.h) |
Very close to Java's Synchronized. Lock and Autolock are well understood. Autounlock's behavior Similar to Autolock, the release lock is constructed, and acquire lock is at the time of destruction. * Application of Raii idiom. |
cookie_manager.cc Examples of *autounlock: Media/filters/audio_renderer_impl.h |
|
Waitableevent (base/synchronization/waitable_event.h) |
Completes the operation with an asynchronous call and waits for the task to complete at the end of the call with a waitableevent. Implemented based on Lock + conditionvariable. |
|
|
Conditionvariable (base/synchronization/condition_variable.h) |
C + + implementation of the condition variable. Main methods: Wait timewait Broadcast Singal |
Inprocesscommandbuffer |
|
Cancellationflag (base/synchronization/cancellation_flag.h) |
Provides a Boolean flag for setting and querying based on atomic operations. |
|
Mechanisms provided by WTF |
Atomicxxx (WTF/ATOMICS.H) |
Atomic classes provided by WebKit |
|
|
Mutex (WTF/TREADINGPRIMITIVES.H) |
Implementation of mutex (platform-based abstraction) Similar to the lock series in base. |
Mutex M_mutex; { Mutexlocker Locker (M_mutex); ...... } |
|
Mutexlock (WTF/TREADINGPRIMITIVES.H) |
|
Recursivemutex (WTF/TREADINGPRIMITIVES.H) |
|
Mutextrylocker (WTF/TREADINGPRIMITIVES.H) |
|
Threadcondition (WTF/TREADINGPRIMITIVES.H) |
Implementation of condition variables |
|
Concurrent containers |
Threadlocalboolean Threadlocalpointer (base/threading/thread_local.h) |
Implementation of TLS (Thread Local stoage) |
Threadlocal applications in threadrestrictions: Lazyinstance<threadlocalboolean>::leaky g_io_disallowed = LAZY_INSTANCE _initializer; |
|
Threadsafedatatransport (wtf/threadsafedatatransport.h) |
Use Sharedbuffer to pass data between a pair of producers and consumers in a thread-safe manner. Reduce thread conflicts and data copies. |
ImageFrameGenerator.h More Instructions |
|
Lazyinstance |
Static member initialization in a function is not thread-safe and prone to pitfalls (C++11 has claimed to be guaranteed). You can use Base::lazyinstance () to resolve, while lazyinstance avoids memory fragmentation, because its objects are created in the data segment. Reference: eliminating static initializers. |
|
Tool class |
Nonthreadsafe |
Only valid under Debug. Provides a protection mechanism for non-thread-safe objects. That is created and used on the same thread. Main method: Calledonvalidthread () |
Refcountedbase also inherits from Nonthreadsafe in later chromium branches. |
|
Threadcollisionwarner (Base/threading/thread_collision_warner.h) |
Provides a set of macros that help ensure thread safety for a class. This mechanism, which stems from threading problem prevention, prevents threading problems at the coding level. Detail reference: "Threading Mess". The main mechanisms offered include:
- Dfake_scoped_lock, restricts a function to run on only one thread.
- Dfake_scoped_recursive_lock, multiple functions can nest calls on the same thread.
- Dfake_scoped_lock_thread_locked, while only one function is allowed to run on the same thread. including creation and deallocation should be on the same thread.
|
|
|
threadchecker (base/threading/thread _checker.h) |
* Only takes effect in debug mode. |
|
|
threadrestrictions (base/threading/ THREAD_RESTRICTIONS.H) |
|
file* OpenFile ( const filepath& filename, Const char * mode) { threadrestrictions:: Assertioallowed (); ... }
|
|
WatchDog (base/threading/watchdog.h) |
Used to monitor a situation in which a thread is unresponsive at a specified time. The main methods are arm () and disarm (). |
In Uma: class shutdownwatchdogthread:public base::watchdog {...} |