DisableThreadLibraryCalls 的作用

第一篇文章

看Wince驱动时,看到Init函数时不时有这个函数,不知道啥意思,

BOOL DisableThreadLibraryCalls(
  HMODULE hLibModule
);

This function disables the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications for the DLL specified by the hLibModule parameter.

Using this function can reduce the size of the working code set for some applications.

Remarks

Windows CE does not support static-thread local storage; therefore, the only restriction for specifying a DLL to disable is that it is a valid module.

The DisableThreadLibraryCalls function lets a DLL disable the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notification calls.

This can be a useful optimization for multithreaded applications that have many DLLs, frequently create and delete threads, and whose DLLs do not need these thread-level notifications of attachment/detachment.

By disabling the notifications, the DLL initialization code is not paged-in because a thread is created or deleted, which reduces the size of the application's working code set.

Disabling the notification calls can be used for any DLL where there is no thread-level tracking required. If you need to track resources on a thread-by-thread basis, the notification should not be turned off.

To implement the optimization, modify a DLL's DLL_PROCESS_ATTACH code to call DisableThreadLibraryCalls.

Drivers that exist in the Device Manager Device.exe process space should call DisableThreadLibraryCalls if no thread-specific data is needed.

 

重点:

This can be a useful optimization for multithreaded applications that have many DLLs, frequently create and delete threads, and whose DLLs do not need these thread-level notifications of attachment/detachment.

该函数在有许多DLL,频繁创建和删除线程,并且DLL不需要线程级消息如DLL_THREAD_ATTACH and DLL_THREAD_DETACH时的多线程应用中是很有效的优化。

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值