本文整理汇总了C++中InterlockedExchangePointer函数的典型用法代码示例。如果您正苦于以下问题:C++ InterlockedExchangePointer函数的具体用法?C++ InterlockedExchangePointer怎么用?C++ InterlockedExchangePointer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InterlockedExchangePointer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: telos_alloc_bufs
static int
telos_alloc_bufs(struct telos_ap *telos, int mtu)
{
int err = -1;
unsigned long len;
char * rbuff = NULL;
char * xbuff = NULL;
/*
* Allocate the TELOS_AP frame buffers:
*
* rbuff Receive buffer.
* xbuff Transmit buffer.
* cbuff Temporary compression buffer.
*/
len = mtu * 2;
/*
* allow for arrival of larger UDP packets, even if we say not to
* also fixes a bug in which SunOS sends 512-byte packets even with
* an MSS of 128
*/
if (len < 576 * 2)
len = 576 * 2;
rbuff = (char *) malloc(len + 4);
if (rbuff == NULL)
goto err_exit;
xbuff = (char *) malloc(len + 4);
if (xbuff == NULL)
goto err_exit;
/*
spin_lock_bh(&telos->lock);
if (telos->tty == NULL) {
spin_unlock_bh(&telos->lock);
err = -ENODEV;
goto err_exit;
}
*/
telos->mtu = mtu;
telos->buffsize = len;
telos->rcount = 0;
telos->xleft = 0;
rbuff = (char*) InterlockedExchangePointer(&telos->rbuff, rbuff);
xbuff = (char*) InterlockedExchangePointer(&telos->xbuff, xbuff);
// spin_unlock_bh(&telos->lock);
err = 0;
/* Cleanup */
err_exit:
if (xbuff)
free(xbuff);
if (rbuff)
free(rbuff);
return err;
}
开发者ID:ekiwi,项目名称:tinyos-1.x,代码行数:56,代码来源:AP_CON.cpp
示例2: MCIQTZ_notifyThread
/***************************************************************************
* MCIQTZ_notifyThread [internal]
*/
static DWORD CALLBACK MCIQTZ_notifyThread(LPVOID parm)
{
WINE_MCIQTZ* wma = (WINE_MCIQTZ *)parm;
HRESULT hr;
HANDLE handle[2];
DWORD n = 0, ret = 0;
handle[n++] = wma->stop_event;
IMediaEvent_GetEventHandle(wma->mevent, (OAEVENT *)&handle[n++]);
for (;;) {
DWORD r;
HANDLE old;
r = WaitForMultipleObjects(n, handle, FALSE, INFINITE);
if (r == WAIT_OBJECT_0) {
TRACE("got stop event\n");
old = InterlockedExchangePointer(&wma->callback, NULL);
if (old)
mciDriverNotify(old, wma->notify_devid, MCI_NOTIFY_ABORTED);
break;
}
else if (r == WAIT_OBJECT_0+1) {
LONG event_code;
LONG_PTR p1, p2;
do {
hr = IMediaEvent_GetEvent(wma->mevent, &event_code, &p1, &p2, 0);
if (SUCCEEDED(hr)) {
TRACE("got event_code = 0x%02x\n", event_code);
IMediaEvent_FreeEventParams(wma->mevent, event_code, p1, p2);
}
} while (hr == S_OK && event_code != EC_COMPLETE);
if (hr == S_OK && event_code == EC_COMPLETE) {
old = InterlockedExchangePointer(&wma->callback, NULL);
if (old)
mciDriverNotify(old, wma->notify_devid, MCI_NOTIFY_SUCCESSFUL);
break;
}
}
else {
TRACE("Unknown error (%d)\n", (int)r);
break;
}
}
hr = IMediaControl_Stop(wma->pmctrl);
if (FAILED(hr)) {
TRACE("Cannot stop filtergraph (hr = %x)\n", hr);
ret = MCIERR_INTERNAL;
}
return ret;
}
开发者ID:kholia,项目名称:wine,代码行数:56,代码来源:mciqtz.c
示例3: PathRemoveFileSpec
BOOL CKTrojanUIHandler::InitKTrojan(BOOL bPreLoad /* = FALSE */)
{
BOOL retval = FALSE;
CreateKTrojanObject_t CreateKTrojanObject = NULL;
TCHAR szKTrojanPath[MAX_PATH] = { 0 };
HRESULT hr;
HMODULE hKTrojan = NULL;
IKTrojan* piKTrojan = NULL;
HWND hWnd = NULL;
if (!m_hKTrajon)
{
::GetModuleFileName(NULL, szKTrojanPath, MAX_PATH);
PathRemoveFileSpec(szKTrojanPath);
PathAppend(szKTrojanPath, _T("kscan.dll"));
hKTrojan = LoadLibrary(szKTrojanPath);
if (!hKTrojan)
goto clean0;
InterlockedExchangePointer((void**)&m_hKTrajon, hKTrojan);
}
if (!m_piKTrajon)
{
CreateKTrojanObject = (CreateKTrojanObject_t)GetProcAddress(m_hKTrajon, "CreateKTrojanObject");
if (!CreateKTrojanObject)
goto clean0;
hr = CreateKTrojanObject(__uuidof(IKTrojan), (void**)&piKTrojan);
if (FAILED(hr))
goto clean0;
InterlockedExchangePointer((void**)&m_piKTrajon, piKTrojan);
}
if (!m_wndKTrojan.m_hWnd)
{
hWnd = m_piKTrajon->CreateKTrojan(m_dlg->GetViewHWND());
InterlockedExchangePointer((void**)&m_wndKTrojan.m_hWnd, hWnd);
m_piKTrajon->SetNotify(m_dlg);
m_piKTrajon->Init();
}
retval = TRUE;
clean0:
if (!retval)
{
UnInitKTrojan();
}
return retval;
}
开发者ID:dreamsxin,项目名称:PcManager,代码行数:52,代码来源:ktrojanuihandler.cpp
示例4: telos_free_bufs
/* Free a TELOS_AP channel buffers. */
static void
telos_free_bufs(struct telos_ap *telos)
{
void * tmp;
// printk(KERN_WARNING "%s: %p\n", __FUNCTION__, telos);
/* Free all TELOS_AP frame buffers. */
if ((tmp = InterlockedExchangePointer(&telos->rbuff, NULL)) != NULL)
free(tmp);
if ((tmp = InterlockedExchangePointer(&telos->xbuff, NULL)) != NULL)
free(tmp);
}
开发者ID:ekiwi,项目名称:tinyos-1.x,代码行数:14,代码来源:AP_CON.cpp
示例5: InterlockedIncrement
// If the cache is not being used reset it
void Cache::ResetCache(IScriptEnvironment* env)
{
InterlockedIncrement(&g_Cache_stats.resets);
minframe = vi.num_frames;
maxframe = -1;
CachedVideoFrame *i, *j;
_RPT3(0, "Cache:%x: Cache Reset, cache_limit %d, cache_init %d\n", this, cache_limit, cache_init<<CACHE_SCALE_SHIFT);
int count=0;
for (i = video_frames.next; i != &video_frames; i = i->next) {
if (++count >= cache_init) goto purge_old_frame;
const int ifn = i->frame_number;
if (ifn < minframe) minframe = ifn;
if (ifn > maxframe) maxframe = ifn;
}
return;
purge_old_frame:
// Truncate the tail of the chain
video_frames.prev = i;
j = (CachedVideoFrame*)InterlockedExchangePointer(&i->next, &video_frames);
// Delete the excess CachedVideoFrames
while (j != &video_frames) {
i = j->next;
ReturnVideoFrameBuffer(j, env); // Return old vfb to vfb pool for early reuse
delete j;
j = i;
}
cache_limit = cache_init << CACHE_SCALE_SHIFT;
}
开发者ID:Sawsan14,项目名称:avisynth,代码行数:35,代码来源:cache.cpp
示例6: ToolHelpHook16
/***********************************************************************
* ToolHelpHook (KERNEL.341)
* see "Undocumented Windows"
*/
FARPROC16 WINAPI ToolHelpHook16(FARPROC16 func)
{
static FARPROC16 hook;
FIXME("(%p), stub.\n", func);
return InterlockedExchangePointer( (void **)&hook, func );
}
开发者ID:Dimillian,项目名称:wine,代码行数:11,代码来源:kernel.c
示例7: InterlockedExchangePointer
void COptex::SetSpinCount(DWORD dwSpinCount) {
// No spinning on single CPU machines
if (!sm_fUniprocessorHost)
InterlockedExchangePointer((PVOID*) &m_psi->m_dwSpinCount,
(PVOID) (DWORD_PTR) dwSpinCount);
}
开发者ID:jinshizi,项目名称:rushcodes,代码行数:7,代码来源:Optex.cpp
示例8: mono_thread_info_uninstall_interrupt
void
mono_thread_info_uninstall_interrupt (gboolean *interrupted)
{
MonoThreadInfo *info;
MonoThreadInfoInterruptToken *previous_token;
g_assert (interrupted);
*interrupted = FALSE;
info = mono_thread_info_current ();
g_assert (info);
previous_token = (MonoThreadInfoInterruptToken *)InterlockedExchangePointer ((gpointer*) &info->interrupt_token, NULL);
/* only the installer can uninstall the token */
g_assert (previous_token);
if (previous_token == INTERRUPT_STATE) {
/* if it is interrupted, then it is going to be freed in finish interrupt */
*interrupted = TRUE;
} else {
g_free (previous_token);
}
THREADS_INTERRUPT_DEBUG ("interrupt uninstall tid %p previous_token %p interrupted %s\n",
mono_thread_info_get_tid (info), previous_token, *interrupted ? "TRUE" : "FALSE");
}
开发者ID:ileonchik,项目名称:mono,代码行数:27,代码来源:mono-threads.c
示例9: MCICDA_Notify
/**************************************************************************
* MCICDA_mciNotify [internal]
*
* Notifications in MCI work like a 1-element queue.
* Each new notification request supersedes the previous one.
*/
static void MCICDA_Notify(DWORD_PTR hWndCallBack, WINE_MCICDAUDIO* wmcda, UINT wStatus)
{
MCIDEVICEID wDevID = wmcda->wNotifyDeviceID;
HANDLE old = InterlockedExchangePointer(&wmcda->hCallback, NULL);
if (old) mciDriverNotify(old, wDevID, MCI_NOTIFY_SUPERSEDED);
mciDriverNotify(HWND_32(LOWORD(hWndCallBack)), wDevID, wStatus);
}
开发者ID:MichaelMcDonnell,项目名称:wine,代码行数:13,代码来源:mcicda.c
示例10: MCICDA_Stop
/**************************************************************************
* MCICDA_Stop [internal]
*/
static DWORD MCICDA_Stop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
WINE_MCICDAUDIO* wmcda = MCICDA_GetOpenDrv(wDevID);
HANDLE oldcb;
DWORD br;
TRACE("(%04X, %08X, %p);\n", wDevID, dwFlags, lpParms);
if (wmcda == NULL) return MCIERR_INVALID_DEVICE_ID;
oldcb = InterlockedExchangePointer(&wmcda->hCallback, NULL);
if (oldcb) mciDriverNotify(oldcb, wmcda->wNotifyDeviceID, MCI_NOTIFY_ABORTED);
if (wmcda->hThread != 0) {
SetEvent(wmcda->stopEvent);
WaitForSingleObject(wmcda->hThread, INFINITE);
CloseHandle(wmcda->hThread);
wmcda->hThread = 0;
CloseHandle(wmcda->stopEvent);
wmcda->stopEvent = 0;
IDirectSoundBuffer_Release(wmcda->dsBuf);
wmcda->dsBuf = NULL;
IDirectSound_Release(wmcda->dsObj);
wmcda->dsObj = NULL;
}
else if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_STOP_AUDIO, NULL, 0, NULL, 0, &br, NULL))
return MCIERR_HARDWARE;
if ((dwFlags & MCI_NOTIFY) && lpParms)
MCICDA_Notify(lpParms->dwCallback, wmcda, MCI_NOTIFY_SUCCESSFUL);
return 0;
}
开发者ID:MichaelMcDonnell,项目名称:wine,代码行数:37,代码来源:mcicda.c
示例11: _HookFastIoRoutine
static VOID _HookFastIoRoutine(PVOID *DriverRoutine, PVOID *RecordRoutine, PVOID HookRoutine)
{
if (*DriverRoutine != NULL)
*RecordRoutine = InterlockedExchangePointer(DriverRoutine, HookRoutine);
return;
}
开发者ID:MartinDrab,项目名称:IRPMon,代码行数:7,代码来源:hook.c
示例12: MCIQTZ_mciNotify
/**************************************************************************
* MCIQTZ_mciNotify [internal]
*
* Notifications in MCI work like a 1-element queue.
* Each new notification request supersedes the previous one.
*/
static void MCIQTZ_mciNotify(DWORD_PTR hWndCallBack, WINE_MCIQTZ* wma, UINT wStatus)
{
MCIDEVICEID wDevID = wma->notify_devid;
HANDLE old = InterlockedExchangePointer(&wma->callback, NULL);
if (old) mciDriverNotify(old, wDevID, MCI_NOTIFY_SUPERSEDED);
mciDriverNotify(HWND_32(LOWORD(hWndCallBack)), wDevID, wStatus);
}
开发者ID:kholia,项目名称:wine,代码行数:13,代码来源:mciqtz.c
示例13: Free
HGLOBAL MGlobal::Alloc(UINT nFlags, size_t cbSize)
{
Free(); // JIC
InterlockedExchangePointer((PVOID*)&mh_Global, GlobalAlloc(nFlags, cbSize));
return mh_Global;
}
开发者ID:1833183060,项目名称:ConEmu,代码行数:7,代码来源:MGlobal.cpp
示例14: BuDebugMessage
BOOL CBackgroundUpdater::Start()
{
BuDebugMessage("CBackgroundUpdater::Start() BEGIN");
if (m_hThread!=NULL)
{
BuDebugMessage("CBackgroundUpdater::Start() ALREADY STARTED");
return FALSE;
}
DWORD dwThreadID;
HANDLE hThread=CreateThread(NULL,0,UpdaterThreadProc,this,CREATE_SUSPENDED,&dwThreadID);
DebugOpenHandle(dhtThread,hThread,"BackgroundUpdater");
DebugFormatMessage("BU started, thread ID=%X",dwThreadID);
if (hThread==NULL)
return FALSE;
InterlockedExchangePointer(&m_hThread,hThread);
SetThreadPriority(m_hThread,THREAD_PRIORITY_BELOW_NORMAL);
InterlockedExchange(&m_lIsWaiting,FALSE);
ResumeThread(m_hThread);
BuDebugMessage("CBackgroundUpdater::Start() END");
return TRUE;
}
开发者ID:eladkarako,项目名称:locate32,代码行数:28,代码来源:Background.cpp
示例15: warning
void* VInterlocked::ExchangeVoidPtr(void** inValue, void* inNewValue)
{
#if VERSIONWIN
#pragma warning (push)
#pragma warning (disable: 4311)
#pragma warning (disable: 4312)
void* val = InterlockedExchangePointer( inValue, inNewValue);
// void* val = (void*) ::InterlockedExchange((long*) inValue, (long)inNewValue);
#pragma warning (pop)
#elif VERSIONMAC
void* val;
do {
val = *inValue;
// one must loop if a swap occured between reading the old val and a failed CAS
// because if we return the old val, the caller may assume that the CAS has succeeded.
} while(!::OSAtomicCompareAndSwapPtrBarrier( val, inNewValue, inValue));
#elif VERSION_LINUX
void* val=__sync_lock_test_and_set(inValue, inNewValue);
#endif
return val;
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:29,代码来源:VInterlocked.cpp
示例16: CancelSelectSuspend
VOID CancelSelectSuspend(IN PTDeviceExtension DeviceExtension)
{
PIRP irp;
KIRQL oldIrql;
irp = NULL;
BulkUsb_DbgPrint(3, ("file bulkdev: CancelSelectSuspend - begins\n"));
KeAcquireSpinLock(&DeviceExtension->IdleReqStateLock, &oldIrql);
if(!CanDeviceSuspend(DeviceExtension))
{
BulkUsb_DbgPrint(3, ("file bulkdev: Device is not idle\n"));
irp = (PIRP)InterlockedExchangePointer(&DeviceExtension->PendingIdleIrp, NULL);
}
KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);
if(irp)
{
IoCancelIrp(irp);
if(0 == InterlockedDecrement(&DeviceExtension->FreeIdleIrpCount))
{
BulkUsb_DbgPrint(3, ("file bulkdev: CancelSelectSuspend frees the irp\n"));
IoFreeIrp(irp);
KeSetEvent(&DeviceExtension->NoIdleReqPendEvent, IO_NO_INCREMENT, FALSE);
}
}
BulkUsb_DbgPrint(3, ("file bulkdev: CancelSelectSuspend - ends\n"));
return;
}
开发者ID:stormbay,项目名称:DragonVer1.0,代码行数:29,代码来源:bulkdev.c
示例17: VirtualProtect
void dx9hook::HookHandler::Release()
{
DWORD oldprot;
VirtualProtect(vft_original_,sizeof(void*),PAGE_EXECUTE_READWRITE,&oldprot);
InterlockedExchangePointer((void**)device_,(void*)vft_original_);
VirtualProtect(vft_original_,sizeof(void*),oldprot,&oldprot);
}
开发者ID:GregLando113,项目名称:dx9hook,代码行数:7,代码来源:dx9hook_base.cpp
示例18: MCICDA_Pause
/**************************************************************************
* MCICDA_Pause [internal]
*/
static DWORD MCICDA_Pause(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
WINE_MCICDAUDIO* wmcda = MCICDA_GetOpenDrv(wDevID);
HANDLE oldcb;
DWORD br;
TRACE("(%04X, %08X, %p);\n", wDevID, dwFlags, lpParms);
if (wmcda == NULL) return MCIERR_INVALID_DEVICE_ID;
oldcb = InterlockedExchangePointer(&wmcda->hCallback, NULL);
if (oldcb) mciDriverNotify(oldcb, wmcda->wNotifyDeviceID, MCI_NOTIFY_ABORTED);
if (wmcda->hThread != 0) {
/* Don't bother calling stop if the playLoop thread has already stopped */
if(WaitForSingleObject(wmcda->stopEvent, 0) != WAIT_OBJECT_0 &&
FAILED(IDirectSoundBuffer_Stop(wmcda->dsBuf)))
return MCIERR_HARDWARE;
}
else if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_PAUSE_AUDIO, NULL, 0, NULL, 0, &br, NULL))
return MCIERR_HARDWARE;
if ((dwFlags & MCI_NOTIFY) && lpParms)
MCICDA_Notify(lpParms->dwCallback, wmcda, MCI_NOTIFY_SUCCESSFUL);
return 0;
}
开发者ID:MichaelMcDonnell,项目名称:wine,代码行数:29,代码来源:mcicda.c
示例19: InterlockedExchangePointer
BOOL CExposeDlg::ResetDevice(IDevice *pDevice, BOOL bInit)
{
if(bInit || m_pDevice != pDevice){
InterlockedExchangePointer((PVOID *)&m_pDevice, pDevice);
EnableWindow(m_pDevice != NULL);
if(m_pDevice != NULL){
DeviceCapability devCapability;
m_pDevice->GetCapability(&devCapability);
m_ctrlAETarget.SetRange(devCapability.sExposureRange.byTargetMin, devCapability.sExposureRange.byTargetMax);
m_ctrlExposeTime.SetRange(devCapability.sExposureRange.usExposureTimeMin, devCapability.sExposureRange.usExposureTimeMax, TRUE);
m_ctrlGain.SetRange(devCapability.sGainRange.ucGainMin,devCapability.sGainRange.ucGainMax);
CheckRadioButton(IDC_RAD_ASPECTRATIO, IDC_RAD_FIXWINDOW, IDC_RAD_ASPECTRATIO);
CheckRadioButton(IDC_JPG, IDC_RAW, IDC_BMP);
BOOL bEnable = m_pDevice->IsMonochromeDevice();
GetDlgItem(IDC_ANALOGGAIN_BAR)->EnableWindow(bEnable);
GetDlgItem(IDC_ANALOGGAIN_TEXT)->EnableWindow(bEnable);
return TRUE;
}
}
return FALSE;
}
开发者ID:githubcjl,项目名称:uVision_cjl,代码行数:25,代码来源:ExposeDlg.cpp
示例20: SelectiveSuspendCompletionRoutine
NTSTATUS SelectiveSuspendCompletionRoutine(PDEVICE_OBJECT pdo, PIRP Irp, UsbDev *pUsbDev)
{
NTSTATUS ntStatus = Irp->IoStatus.Status;
DBGU_TRACE("SelectiveSuspendCompletionRoutine: 0x%08X\n",ntStatus);
//test
/*if (InterlockedExchangePointer((PVOID *)&pUsbDev->m_SuspendIrp, NULL))
{
DBGU_TRACE("IoFreeIrp Suspend IRP at Completion Routine..\n");
IoFreeIrp(Irp);
}*/
InterlockedExchangePointer((PVOID *)&pUsbDev->m_SuspendIrp, NULL);
DBGU_TRACE("IoFreeIrp Suspend IRP at Completion Routine..\n");
IoFreeIrp(Irp);
// fix incorrect power state transition during S0 -> S3 (ymwu, 2005/7/16)
// this irp will be cancelled when system power state is changed to S3
// device power state should not be set to D0 in this situation
// if you make incorrect power state transition, the system sometimes hangs
{
DBGU_TRACE("Cancel Selective Suspend..\n");
pUsbDev->m_SuspendCancelled = 1;
}
KeSetEvent(&pUsbDev->m_SuspendIrpCancelEvent, IO_NO_INCREMENT, FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
}
开发者ID:rancky,项目名称:skinvideo-driver,代码行数:28,代码来源:UsbDev.cpp
注:本文中的InterlockedExchangePointer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论