|
Packit Service |
fa4841 |
/**
|
|
Packit Service |
fa4841 |
* WinPR: Windows Portable Runtime
|
|
Packit Service |
fa4841 |
* Thread Pool API (Callback)
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
Packit Service |
fa4841 |
* you may not use this file except in compliance with the License.
|
|
Packit Service |
fa4841 |
* You may obtain a copy of the License at
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit Service |
fa4841 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit Service |
fa4841 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit Service |
fa4841 |
* See the License for the specific language governing permissions and
|
|
Packit Service |
fa4841 |
* limitations under the License.
|
|
Packit Service |
fa4841 |
*/
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
fa4841 |
#include "config.h"
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#include <winpr/crt.h>
|
|
Packit Service |
fa4841 |
#include <winpr/pool.h>
|
|
Packit Service |
fa4841 |
#include <winpr/library.h>
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef WINPR_THREAD_POOL
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef _WIN32
|
|
Packit Service |
fa4841 |
static INIT_ONCE init_once_module = INIT_ONCE_STATIC_INIT;
|
|
Packit Service |
bb5c11 |
static BOOL (WINAPI * pCallbackMayRunLong)(PTP_CALLBACK_INSTANCE pci);
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
bb5c11 |
static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID *context)
|
|
Packit Service |
fa4841 |
{
|
|
Packit Service |
fa4841 |
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
|
|
Packit Service |
fa4841 |
if (kernel32)
|
|
Packit Service |
fa4841 |
{
|
|
Packit Service |
fa4841 |
pCallbackMayRunLong = (void*)GetProcAddress(kernel32, "CallbackMayRunLong");
|
|
Packit Service |
fa4841 |
}
|
|
Packit Service |
fa4841 |
return TRUE;
|
|
Packit Service |
fa4841 |
}
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
BOOL CallbackMayRunLong(PTP_CALLBACK_INSTANCE pci)
|
|
Packit Service |
fa4841 |
{
|
|
Packit Service |
fa4841 |
#ifdef _WIN32
|
|
Packit Service |
fa4841 |
InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
|
|
Packit Service |
fa4841 |
if (pCallbackMayRunLong)
|
|
Packit Service |
fa4841 |
return pCallbackMayRunLong(pci);
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
/* No default implementation */
|
|
Packit Service |
fa4841 |
return FALSE;
|
|
Packit Service |
fa4841 |
}
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#endif /* WINPR_THREAD_POOL defined */
|