本文整理汇总了C++中InitOnceExecuteOnce函数的典型用法代码示例。如果您正苦于以下问题:C++ InitOnceExecuteOnce函数的具体用法?C++ InitOnceExecuteOnce怎么用?C++ InitOnceExecuteOnce使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InitOnceExecuteOnce函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: primitives_get
/* ------------------------------------------------------------------------- */
primitives_t* primitives_get(void)
{
InitOnceExecuteOnce(&generic_primitives_InitOnce, primitives_init_generic, NULL, NULL);
#if defined(HAVE_OPTIMIZED_PRIMITIVES)
InitOnceExecuteOnce(&primitives_InitOnce, primitives_init, NULL, NULL);
return &pPrimitives;
#else
return &pPrimitivesGeneric;
#endif
}
示例2: get_notif_hwnd
HWND get_notif_hwnd(void)
{
#ifdef __REACTOS__
static ATOM wnd_class = 0;
#endif
tls_data_t *tls_data;
#ifdef __REACTOS__
static const WCHAR wszURLMonikerNotificationWindow[] =
{'U','R','L',' ','M','o','n','i','k','e','r',' ',
'N','o','t','i','f','i','c','a','t','i','o','n',' ','W','i','n','d','o','w',0};
#else
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
#endif
tls_data = get_tls_data();
if(!tls_data)
return NULL;
if(tls_data->notif_hwnd_cnt) {
tls_data->notif_hwnd_cnt++;
return tls_data->notif_hwnd;
}
#ifndef __REACTOS__
InitOnceExecuteOnce(&init_once, register_notif_wnd_class, NULL, NULL);
if(!notif_wnd_class)
return NULL;
#else
if(!wnd_class) {
static WNDCLASSEXW wndclass = {
sizeof(wndclass), 0,
notif_wnd_proc, 0, 0,
NULL, NULL, NULL, NULL, NULL,
wszURLMonikerNotificationWindow,
NULL
};
wndclass.hInstance = hProxyDll;
wnd_class = RegisterClassExW(&wndclass);
if (!wnd_class && GetLastError() == ERROR_CLASS_ALREADY_EXISTS)
wnd_class = 1;
}
#endif
#ifndef __REACTOS__
tls_data->notif_hwnd = CreateWindowExW(0, MAKEINTRESOURCEW(notif_wnd_class),
#else
tls_data->notif_hwnd = CreateWindowExW(0, wszURLMonikerNotificationWindow,
#endif
wszURLMonikerNotificationWindow, 0, 0, 0, 0, 0, HWND_MESSAGE,
NULL, hProxyDll, NULL);
if(tls_data->notif_hwnd)
tls_data->notif_hwnd_cnt++;
TRACE("hwnd = %p\n", tls_data->notif_hwnd);
return tls_data->notif_hwnd;
}
示例3: winpr_CloseThreadpool
VOID winpr_CloseThreadpool(PTP_POOL ptpp)
{
#ifdef _WIN32
InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
if (pCloseThreadpool)
{
pCloseThreadpool(ptpp);
return;
}
#endif
SetEvent(ptpp->TerminateEvent);
ArrayList_Free(ptpp->Threads);
Queue_Free(ptpp->PendingQueue);
CountdownEvent_Free(ptpp->WorkComplete);
CloseHandle(ptpp->TerminateEvent);
if (ptpp == &DEFAULT_POOL)
{
ptpp->Threads = NULL;
ptpp->PendingQueue = NULL;
ptpp->WorkComplete = NULL;
ptpp->TerminateEvent = NULL;
}
else
{
free(ptpp);
}
}
示例4: tMPI_Thread_once
int tMPI_Thread_once(tMPI_Thread_once_t *once_control,
void (*init_routine)(void))
{
#if 0
/* use once Vista is minimum required version */
BOOL bStatus;
bStatus = InitOnceExecuteOnce(once_control, InitHandleWrapperFunction,
init_routine, NULL);
if (!bStatus)
{
tMPI_Fatal_error(TMPI_FARGS,"Failed to run thread_once routine");
return -1;
}
#else
/* really ugly hack - and it's slow... */
tMPI_Init_initers();
EnterCriticalSection(&once_init);
if (tMPI_Atomic_get(&(once_control->once)) == 0)
{
(*init_routine)();
tMPI_Atomic_set(&(once_control->once), 1);
}
LeaveCriticalSection(&once_init);
#endif
return 0;
}
示例5: IsAtMostWindowsVersion
bool IsAtMostWindowsVersion(WindowsVersion version)
{
#ifdef OVR_OS_MS
if (!InitOnceExecuteOnce(&OSVersionInitOnce, VersionCheckInitOnceCallback, nullptr, nullptr))
{
OVR_ASSERT(false);
return false;
}
switch (version)
{
case WindowsVersion::Windows10_TH2:
return (OSVersion < 1000) || (OSVersion == 1000 && OSBuildNumber <= 10586);
case WindowsVersion::Windows10:
return (OSVersion < 1000) || (OSVersion == 1000 && OSBuildNumber == 10000);
case WindowsVersion::Windows8_1:
return (OSVersion <= 603);
case WindowsVersion::Windows8:
return (OSVersion <= 602);
case WindowsVersion::Windows7_SP1:
return (OSVersion < 601) || (OSVersion == 601 && OSBuildNumber <= 7601);
default:
OVR_ASSERT(false); // Forget to add a case for a new OS?
return false;
}
#else // OVR_OS_MS
OVR_UNUSED(version);
return false;
#endif // OVR_OS_MS
}
示例6: winpr_SetThreadpoolThreadMinimum
BOOL winpr_SetThreadpoolThreadMinimum(PTP_POOL ptpp, DWORD cthrdMic)
{
HANDLE thread;
#ifdef _WIN32
InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
if (pSetThreadpoolThreadMinimum)
return pSetThreadpoolThreadMinimum(ptpp, cthrdMic);
#endif
ptpp->Minimum = cthrdMic;
while (ArrayList_Count(ptpp->Threads) < ptpp->Minimum)
{
if (!(thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) thread_pool_work_func,
(void*) ptpp, 0, NULL)))
{
return FALSE;
}
if (ArrayList_Add(ptpp->Threads, thread) < 0)
return FALSE;
}
return TRUE;
}
示例7: get_notif_hwnd
HWND get_notif_hwnd(void)
{
tls_data_t *tls_data;
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
tls_data = get_tls_data();
if(!tls_data)
return NULL;
if(tls_data->notif_hwnd_cnt) {
tls_data->notif_hwnd_cnt++;
return tls_data->notif_hwnd;
}
InitOnceExecuteOnce(&init_once, register_notif_wnd_class, NULL, NULL);
if(!notif_wnd_class)
return NULL;
tls_data->notif_hwnd = CreateWindowExW(0, MAKEINTRESOURCEW(notif_wnd_class),
wszURLMonikerNotificationWindow, 0, 0, 0, 0, 0, HWND_MESSAGE,
NULL, hProxyDll, NULL);
if(tls_data->notif_hwnd)
tls_data->notif_hwnd_cnt++;
TRACE("hwnd = %p\n", tls_data->notif_hwnd);
return tls_data->notif_hwnd;
}
示例8: CRYPTO_THREAD_run_once
int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
{
if (InitOnceExecuteOnce(once, once_cb, init, NULL))
return 1;
return 0;
}
示例9: sspi_gss_init_sec_context
UINT32 SSPI_GSSAPI sspi_gss_init_sec_context(
UINT32* minor_status,
sspi_gss_cred_id_t claimant_cred_handle,
sspi_gss_ctx_id_t* context_handle,
sspi_gss_name_t target_name,
sspi_gss_OID mech_type,
UINT32 req_flags,
UINT32 time_req,
sspi_gss_channel_bindings_t input_chan_bindings,
sspi_gss_buffer_t input_token,
sspi_gss_OID* actual_mech_type,
sspi_gss_buffer_t output_token,
UINT32* ret_flags,
UINT32* time_rec)
{
SECURITY_STATUS status;
InitOnceExecuteOnce(&g_Initialized, sspi_GssApiInit, NULL, NULL);
if (!(g_GssApi && g_GssApi->gss_init_sec_context))
return SEC_E_UNSUPPORTED_FUNCTION;
status = g_GssApi->gss_init_sec_context(minor_status, claimant_cred_handle, context_handle,
target_name, mech_type, req_flags, time_req, input_chan_bindings,
input_token, actual_mech_type, output_token, ret_flags, time_rec);
WLog_DBG(TAG, "gss_init_sec_context: %s (0x%08"PRIX32")",
GetSecurityStatusString(status), status);
return status;
}
示例10: sspi_gss_accept_sec_context
UINT32 SSPI_GSSAPI sspi_gss_accept_sec_context(
UINT32* minor_status,
sspi_gss_ctx_id_t* context_handle,
sspi_gss_cred_id_t acceptor_cred_handle,
sspi_gss_buffer_t input_token_buffer,
sspi_gss_channel_bindings_t input_chan_bindings,
sspi_gss_name_t* src_name,
sspi_gss_OID* mech_type,
sspi_gss_buffer_t output_token,
UINT32* ret_flags,
UINT32* time_rec,
sspi_gss_cred_id_t* delegated_cred_handle)
{
SECURITY_STATUS status;
InitOnceExecuteOnce(&g_Initialized, sspi_GssApiInit, NULL, NULL);
if (!(g_GssApi && g_GssApi->gss_accept_sec_context))
return SEC_E_UNSUPPORTED_FUNCTION;
status = g_GssApi->gss_accept_sec_context(minor_status, context_handle, acceptor_cred_handle,
input_token_buffer, input_chan_bindings, src_name, mech_type, output_token,
ret_flags, time_rec, delegated_cred_handle);
WLog_DBG(TAG, "gss_accept_sec_context: %s (0x%08"PRIX32")",
GetSecurityStatusString(status), status);
return status;
}
示例11: sspi_gss_add_cred
UINT32 SSPI_GSSAPI sspi_gss_add_cred(
UINT32* minor_status,
sspi_gss_cred_id_t input_cred_handle,
sspi_gss_name_t desired_name,
sspi_gss_OID desired_mech,
sspi_gss_cred_usage_t cred_usage,
UINT32 initiator_time_req,
UINT32 acceptor_time_req,
sspi_gss_cred_id_t* output_cred_handle,
sspi_gss_OID_set* actual_mechs,
UINT32* initiator_time_rec,
UINT32* acceptor_time_rec)
{
SECURITY_STATUS status;
InitOnceExecuteOnce(&g_Initialized, sspi_GssApiInit, NULL, NULL);
if (!(g_GssApi && g_GssApi->gss_add_cred))
return SEC_E_UNSUPPORTED_FUNCTION;
status = g_GssApi->gss_add_cred(minor_status, input_cred_handle, desired_name, desired_mech,
cred_usage,
initiator_time_req, acceptor_time_req, output_cred_handle, actual_mechs, initiator_time_rec,
acceptor_time_rec);
WLog_DBG(TAG, "gss_add_cred: %s (0x%08"PRIX32")",
GetSecurityStatusString(status), status);
return status;
}
示例12: global_init
static void
global_init(void)
{
InitOnceExecuteOnce(&global_init_once,
global_init1,
nullptr, nullptr);
}
示例13: lockEnsureGlobalLock
static void lockEnsureGlobalLock(void)
{
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
BOOL b = InitOnceExecuteOnce(&init_once, lockEnsureGlobalLockCallback,
UNUSED_POINTER, NULL);
AVER(b);
}
示例14: ssd
sp_session *SpotifySession::get(abort_callback & p_abort) {
SpotifySessionData ssd(p_abort, this);
InitOnceExecuteOnce(&initOnce,
makeSpotifySession,
&ssd,
NULL);
return getAnyway();
}
示例15: FspWin32FromNtStatus
FSP_API DWORD FspWin32FromNtStatus(NTSTATUS Status)
{
InitOnceExecuteOnce(&FspNtStatusInitOnce, FspNtStatusInitialize, 0, 0);
if (0 == FspRtlNtStatusToDosError)
return ERROR_MR_MID_NOT_FOUND;
return FspRtlNtStatusToDosError(Status);
}