log4cplus的实现 - windows下DllMain禁止调用锁或者加载dll的折衷处理

global-init.cxx 中代码,使用 QueueUserAPC, windows的异步线程调度方式,可以避免dllmain的限制。

https://docs.microsoft.com/zh-cn/windows/desktop/api/processthreadsapi/nf-processthreadsapi-queueuserapc

Adds a user-mode asynchronous procedure call (APC) object to the APC queue of the specified thread.

Syntax

C++复制

DWORD QueueUserAPC(
  PAPCFUNC  pfnAPC,
  HANDLE    hThread,
  ULONG_PTR dwData
);

Parameters

pfnAPC

A pointer to the application-supplied APC function to be called when the specified thread performs an alertable wait operation. For more information, see APCProc.

hThread

A handle to the thread. The handle must have the THREAD_SET_CONTEXT access right. For more information, see Synchronization Object Security and Access Rights.

dwData

A single value that is passed to the APC function pointed to by the pfnAPC parameter.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastErrorWindows Server 2003 and Windows XP:  There are no error values defined for this function that can be retrieved by calling GetLastError.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值