AutoMutex _l(mLock)
来源:互联网 发布:文言文虚词乎 编辑:程序博客网 时间:2024/05/01 01:17
http://www.baidu.com/s?wd=android+AutoMutex&ie=UTF-8
http://blog.csdn.net/evilcode/article/details/8291934
http://blog.csdn.net/batoom/article/details/8314144
AutoMutex is defined in D:\linux\linuxkernel\src\cm10.1\frameworks\native\include\utils\Mutex.h
/*
* Automatic mutex. Declare one of these at the top of a function.
* When the function returns, it will go out of scope, and release the
* mutex.
*/
typedef Mutex::Autolock AutoMutex;
// Manages the mutex automatically. It'll be locked when Autolock is
// constructed and released when Autolock goes out of scope.
class Autolock {
public:
inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); }
inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); }
inline ~Autolock() { mLock.unlock(); }
private:
Mutex& mLock;
};
example:
D:\linux\linuxkernel\src\cm10.1\frameworks\av\include\media\IMediaDeathNotifier.h
class IMediaDeathNotifier: virtual public RefBase
{
static Mutex sServiceLock;
D:\linux\linuxkernel\src\cm10.1\frameworks\av\media\libmedia\IMediaDeathNotifier.cpp
// client singleton for binder interface to services
Mutex IMediaDeathNotifier::sServiceLock;
IMediaDeathNotifier::getMediaPlayerService()
{
ALOGV("getMediaPlayerService");
Mutex::Autolock _l(sServiceLock);
.......
D:\linux\linuxkernel\src\cm10.1\frameworks\base\services\jni\com_android_server_input_InputManagerService.cpp
NativeInputManager::NativeInputManager(jobject contextObj,
jobject serviceObj, const sp<Looper>& looper) :
mLooper(looper) {
JNIEnv* env = jniEnv();
mContextObj = env->NewGlobalRef(contextObj);
mServiceObj = env->NewGlobalRef(serviceObj);
{
AutoMutex _l(mLock);
mLocked.systemUiVisibility = ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE;
mLocked.pointerSpeed = 0;
mLocked.pointerGesturesEnabled = true;
mLocked.showTouches = false;
mLocked.stylusIconEnabled = false;
}
sp<EventHub> eventHub = new EventHub();
mInputManager = new InputManager(eventHub, this, this);
}
frameworks/base/libs/binder/IServiceManager.cpp
[cpp] view plaincopy
sp<IServiceManager> defaultServiceManager()
{
if (gDefaultServiceManager != NULL) return gDefaultServiceManager;
{
AutoMutex _l(gDefaultServiceManagerLock);
if (gDefaultServiceManager == NULL) {
gDefaultServiceManager = interface_cast<IServiceManager>(
ProcessState::self()->getContextObject(NULL));
}
}
return gDefaultServiceManager;
}
- AutoMutex _l(mLock)
- AutoMutex
- AutoMutex
- _T,_L...
- android 里面的 AutoMutex
- android 里面的 AutoMutex
- Android中的AutoMutex
- android 里面的 AutoMutex
- android 里面的 AutoMutex
- 系统调用 mlock
- _T ,_L的含义
- _T和_L
- android的自动锁AutoMutex
- Android 线程同步之AutoMutex
- linux mlockall mlock munlock munlockall
- mlock家族:锁定物理内存
- mlock家族:锁定物理内存 .
- mlock家族:锁定物理内存
- delphi设置程序日期格式
- ListView加上Header和Footer后数据更新
- 代理模式(Proxy)
- 15种基础的可以直接使用的CSS3样式
- JavaScript中的原型和对象机制
- AutoMutex _l(mLock)
- 宫格格用法
- C++从一个文件中统计所有出现过的单词,并按次数从大到小输出
- GIT & REPO & GERRIT (一)
- ConfigurationPrinter
- 网站设计想要冲破传统,首先需要知道什么是传统
- 获取客户端IP
- 谈谈Java:Checked Exception与Runtime Exception 的区别
- hadoop同步集群个节点命令rsync