码迷,mamicode.com
首页 > 其他好文 > 详细

SmallLocks

时间:2018-07-24 14:04:02      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:info   struct   nal   use   eof   ack   pos   ble   wrap   

folly/SmallLocks.h

This module is currently x64 only.

This header defines two very small mutex types. These are useful in highly memory-constrained environments where contention is unlikely. The purpose of these is to allow fine-grained locking in massive data structures where memory is at a premium. Often, each record may have a spare bit or byte lying around, so sometimes these can be tacked on with no additional memory cost.

There are two types exported from this header. MicroSpinLock is a single byte lock, and PicoSpinLock can be wrapped around an integer to use a single bit as a lock. Why do we have both? Because you can‘t use x64 bts on a single byte, sosizeof(MicroSpinLock) is smaller than sizeof(PicoSpinLock) can be, giving it some use cases.

Both the locks in this header model the C++11 Lockable concept. So you can use std::lock_guard or std::unique_lock to lock them in an RAII way if you want.

Additional information is in the header.

SmallLocks

标签:info   struct   nal   use   eof   ack   pos   ble   wrap   

原文地址:https://www.cnblogs.com/lenmom/p/9359382.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!