Android 的sp 和 wp 类模板 以及RefBase类

sp 和 wp 类模板 以及RefBase类的代码在frameworks/base/include/utils/RefBase.h 和 frameworks/base/libs/utils/RefBase.cpp 中。
sp是Strong pointer ,wp是Weak pointer , 是实现android C++ 自动内存分配和回收避免内存泄漏的机制,类似于java的垃圾回收机制。sp 和 wp除了以上功能,并不做过多的其它任务。
有了以上基础,再来理解frameworks/base/cmds/bootanimation/bootanimation_main.cpp这个文件中的下面代码。


int main(int argc,char** argv)
{
#if defined(HAVE_PTHREADS)
setpriority(PRIO_PROCESS,0, ANDROID_PRIORITY_DISPLAY);
#endif

char value[PROPERTY_VALUE_MAX];
property_get("debug.sf.nobootanimation", value,"0");
int noBootAnimation = atoi(value);
LOGI_IF(noBootAnimation,"boot animation disabled");
if(!noBootAnimation){

sp<ProcessState> proc(ProcessState::self());
ProcessState::self()->startThreadPool();

// create the boot animation object
sp<BootAnimation> boot =newBootAnimation();

IPCThreadState::self()->joinThreadPool();

}
return0;
}


这又涉及到native service,IPC和BinderNative Service是在系统Init阶段通过Init.rc脚本建立的服务 。继续看这两篇文: http://blog.csdn.net/maxleng/article/details/5504485和   http://blog.csdn.net/maxleng/article/details/5490770

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值