这篇教程C++ HasOverlappedIoCompleted函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中HasOverlappedIoCompleted函数的典型用法代码示例。如果您正苦于以下问题:C++ HasOverlappedIoCompleted函数的具体用法?C++ HasOverlappedIoCompleted怎么用?C++ HasOverlappedIoCompleted使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了HasOverlappedIoCompleted函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: lockDWORD WINAPI CEgTcpDriver::Stop(){ CAutoLock lock(&m_InitLock); if (!m_bInited) return ERROR_SERVICE_NOT_ACTIVE; m_bInited = FALSE; WSASetEvent(m_hWsaEvents[WSASHUTDOWN_EVENT]); WaitForSingleObject(m_hWSAEventThread, INFINITE); CloseHandle(m_hWSAEventThread); for (DWORD i = 0; i < m_dwThreadCount; i++) PostQueuedCompletionStatus(m_hIocp, 0, 0, NULL); HANDLE * ThreadHandles = new HANDLE[m_dwThreadCount]; for (i = 0; i < m_dwThreadCount; i++) ThreadHandles[i] = m_hThreads[i]; WaitForMultipleObjects(m_dwThreadCount, ThreadHandles, TRUE, INFINITE); delete [] ThreadHandles; for (i = 0; i < m_dwThreadCount; i++) CloseHandle(m_hThreads[i]); m_hThreads.clear(); if (m_usServerPort != CLIENT_ONLY) { closesocket(m_ListenSocket); closesocket(m_ListenSocketContext.m_pIOContext.m_SocketAccept); while (!HasOverlappedIoCompleted((LPOVERLAPPED)&m_ListenSocketContext.m_pIOContext.m_SendOverlapped)) Sleep(0); while (!HasOverlappedIoCompleted((LPOVERLAPPED)&m_ListenSocketContext.m_pIOContext.m_ReceiveOverlapped)) Sleep(0); } CloseHandle(m_hIocp); for(i = 0; i < WSATOTAL_EVENTS; i++) WSACloseEvent(m_hWsaEvents[i]); for(set<PER_SOCKET_CONTEXT>::iterator it = m_SocketContexts.begin(); it != m_SocketContexts.end(); ) { set<PER_SOCKET_CONTEXT>::iterator DelIt = it; it++; CloseClient(*DelIt); } return 0;}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:58,
示例2: DestroyWatch/// Stops monitoring a directory.void DestroyWatch(WatchStruct* pWatch){ if(!pWatch) return; pWatch->mStopNow = TRUE; // Cancels all pending input and output (I/O) operations // that are issued by the calling thread for the specified file. // The function does not cancel I/O operations that other threads issue for a file handle. // If the function succeeds, the return value is nonzero. // //const BOOL bCancelIoResult = CancelIo(pWatch->mDirHandle); //(void)bCancelIoResult; RefreshWatch(pWatch, true); if (!HasOverlappedIoCompleted(&pWatch->mOverlapped)) { SleepEx(5, TRUE); } CloseHandle(pWatch->mOverlapped.hEvent); CloseHandle(pWatch->mDirHandle); HeapFree(GetProcessHeap(), 0, pWatch); Assert(numWatches > 0); --numWatches;}
开发者ID:S-V,项目名称:Lollipop,代码行数:30,
示例3: pLockBOOL CALLBACK CCircuitry::OnRecMemBlockDone(int ch, int nEndReason, PUCHAR pucBuf, DWORD dwStopOffset, PVOID pV){ enum { RecordBy_BlockApp = 1, RecordBy_RcvDtmf = 2, RecordBy_Hangup = 3, RecordBy_Done = 4, }; if ( SsmGetChState(ch) == S_CALL_STANDBY ) nEndReason = RecordBy_Hangup; OVERLAPPED* pRecIoOver = (OVERLAPPED*)pV;//TRACE("%i-> OnRecMemBlockDone in [%i]/n", GetTickCount(), pRecIoOver->Offset); CSingleLock pLock( &Neighbour.m_pSection ); for ( ; HasOverlappedIoCompleted(pRecIoOver) && ! pLock.Lock(50); ); if ( ! --pRecIoOver->Offset ) SetEvent( pRecIoOver->hEvent ); CCircuitry* pChannel = (CCircuitry*) pRecIoOver->InternalHigh; if ( nEndReason == RecordBy_Done && pLock.IsLocked() ) { pChannel->RecordWith( ch, pucBuf, min(dwStopOffset,TEMP_BUFFER) ); } else if ( nEndReason != RecordBy_Done ) { pRecIoOver->OffsetHigh = -1; if ( nEndReason == RecordBy_Hangup ) pChannel->m_nTaskId = -1; } return TRUE;}
开发者ID:pics860,项目名称:callcenter,代码行数:33,
示例4: eof_timer_cbstatic void eof_timer_cb(uv_timer_t* timer, int status) { uv_pipe_t* pipe = (uv_pipe_t*) timer->data; uv_loop_t* loop = timer->loop; assert(status == 0); /* timers can't fail */ assert(pipe->type == UV_NAMED_PIPE); /* This should always be true, since we start the timer only */ /* in uv_pipe_queue_read after successfully calling ReadFile, */ /* or in uv_process_pipe_shutdown_req if a read is pending, */ /* and we always immediately stop the timer in */ /* uv_process_pipe_read_req. */ assert(pipe->flags & UV_HANDLE_READ_PENDING); /* If there are many packets coming off the iocp then the timer callback */ /* may be called before the read request is coming off the queue. */ /* Therefore we check here if the read request has completed but will */ /* be processed later. */ if ((pipe->flags & UV_HANDLE_READ_PENDING) && HasOverlappedIoCompleted(&pipe->read_req.overlapped)) { return; } /* Force both ends off the pipe. */ CloseHandle(pipe->handle); pipe->handle = INVALID_HANDLE_VALUE; /* Stop reading, so the pending read that is going to fail will */ /* not be reported to the user. */ uv_read_stop((uv_stream_t*) pipe); /* Report the eof and update flags. This will get reported even if the */ /* user stopped reading in the meantime. TODO: is that okay? */ uv_pipe_read_eof(loop, pipe, uv_null_buf_);}
开发者ID:Cycle-Applications,项目名称:node,代码行数:35,
示例5: RecordWithint CCircuitry::RecordWith(int nChan, BYTE* pBuffer, DWORD dwStopOffset){ if ( ! m_pChain || ! m_pChain->IsConnected() ) return -1; if ( m_pRecIoOver->Offset >= MAX_RECLST ) return -1; if ( ! HasOverlappedIoCompleted(m_pRecIoOver) ) return -1; CBuffer* pOutput = m_pChain->m_pOutput; if ( dwStopOffset ) pOutput->Add( pBuffer, dwStopOffset + 1 ); Neighbour.m_pWakeup.SetEvent(); if ( int nResult = SsmRecordMemBlock(nChan, 6, pBuffer, TEMP_BUFFER, OnRecMemBlockDone, m_pRecIoOver) ) {#ifdef _DEBUG CHAR sError[1024]; SsmGetLastErrMsg( sError ); theApp.Message( MSG_ERROR, sError );#endif return nResult; } m_pRecIoOver->Offset++; ResetEvent( m_pRecIoOver->hEvent ); //TRACE("%i-> RecordWith in [%i]/n", GetTickCount(), m_pRecIoOver->Offset); return 0;}
开发者ID:pics860,项目名称:callcenter,代码行数:28,
示例6: gry_check// pb with this code: works if no receiving of chars has been previously donestatic int gry_check(CableHandle *h, int *status){ BOOL fSuccess; static DWORD dwEvtMask = 0; static OVERLAPPED ol = { 0 }; static BOOL iop; static BOOL ioPending = FALSE; if (ioPending == FALSE) { memset(&ol, 0, sizeof(OVERLAPPED)); fSuccess = WaitCommEvent(hCom, &dwEvtMask, &ol); ioPending = TRUE; printf("$ (%i)/n", ioPending); } else { if (HasOverlappedIoCompleted(&ol)) { if (dwEvtMask & EV_RXCHAR) { *status = STATUS_RX; printf("#/n"); ioPending = FALSE; } } } return 0;}
开发者ID:TC01,项目名称:tilibs,代码行数:33,
示例7: gry_getstatic int gry_get(CableHandle* h, uint8_t *data, uint32_t len){ BOOL fSuccess; DWORD nBytesRead; OVERLAPPED ol; uint32_t i; for(i = 0; i < len;) { memset(&ol, 0, sizeof(OVERLAPPED)); fSuccess = ReadFile(hCom, data + i, len - i, &nBytesRead, &ol); while(HasOverlappedIoCompleted(&ol) == FALSE) Sleep(0); fSuccess = GetOverlappedResult(hCom, &ol, &nBytesRead, FALSE); if (!fSuccess) { ticables_warning("ReadFile"); return ERR_READ_ERROR; } else if (nBytesRead == 0) { ticables_warning("ReadFile"); return ERR_READ_TIMEOUT; } i += nBytesRead; } printf("get : %i %i %i/n", fSuccess, nBytesRead, len); return 0;}
开发者ID:TC01,项目名称:tilibs,代码行数:32,
示例8: gry_putstatic int gry_put(CableHandle* h, uint8_t *data, uint32_t len){ BOOL fSuccess; DWORD nBytesWritten; OVERLAPPED ol; memset(&ol, 0, sizeof(OVERLAPPED)); fSuccess = WriteFile(hCom, data, len, &nBytesWritten, &ol); while(HasOverlappedIoCompleted(&ol) == FALSE) Sleep(0); fSuccess = GetOverlappedResult(hCom, &ol, &nBytesWritten, FALSE); if (!fSuccess) { ticables_warning("WriteFile"); return ERR_WRITE_ERROR; } else if (nBytesWritten == 0) { ticables_warning("WriteFile"); return ERR_WRITE_TIMEOUT; } else if (nBytesWritten < len) { ticables_warning("WriteFile"); return ERR_WRITE_ERROR; } return 0;}
开发者ID:TC01,项目名称:tilibs,代码行数:30,
示例9: RCX_receiveint RCX_receive(unsigned char *rcbuf, unsigned long length){ //attempts to read a message of specified length from the RCX unsigned long res=0; int i; ovl.Offset=0; ovl.OffsetHigh=0; ovl.hEvent=NULL; if (!ReadFile(RCX_port,rcbuf,length,&res,&ovl)){ //return(0); if (GetLastError()==ERROR_IO_PENDING){ i=0; do{ Sleep(10); i++; } while ((!HasOverlappedIoCompleted(&ovl))&&(i<50)); if (i<50){ GetOverlappedResult(RCX_port,&ovl,&res,FALSE); return(res); //completed. } else { CancelIo(RCX_port); //cancel transmission. return(0); //not completed. } } else { //some error occured CancelIo(RCX_port); //cancel transmission. return(0); } } return(res);}
开发者ID:rkovessy,项目名称:VeWalker,代码行数:30,
示例10: HasOverlappedIoCompletedbool File::HasAsyncIOCompleted(){#if _WIN32 || _WIN64 return HasOverlappedIoCompleted( &m_overlapped );#else return false;#endif}
开发者ID:nsweb,项目名称:bigball,代码行数:8,
示例11: USBDevice_internalFlushvoid USBDevice_internalFlush(LPSKYETEK_DEVICE device, BOOL lockSendBuffer){ #ifndef WINCE OVERLAPPED overlap; #else COMMTIMEOUTS ctos; DEVICEIMPL* pImpl; #endif unsigned char sendBuffer[65]; LPUSB_DEVICE usbDevice; unsigned int bytesWritten; if(device == NULL) return; usbDevice = (LPUSB_DEVICE)device->user; if(lockSendBuffer) EnterCriticalSection(&usbDevice->sendBufferMutex); if(usbDevice->sendBufferWritePtr == usbDevice->sendBuffer) goto end; /* Windows HID command */ sendBuffer[0] = 0; /* Actual length of data */ sendBuffer[1] = (usbDevice->sendBufferWritePtr - usbDevice->sendBuffer); CopyMemory((sendBuffer + 2), usbDevice->sendBuffer, sendBuffer[1]); bytesWritten = 0; #ifndef WINCE ZeroMemory(&overlap, sizeof(OVERLAPPED)); overlap.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); WriteFile(device->writeFD, sendBuffer, 65, &bytesWritten, &overlap); WaitForSingleObject(overlap.hEvent, 100); CloseHandle(overlap.hEvent); if(!HasOverlappedIoCompleted(&overlap)) CancelIo(device->writeFD);#else pImpl = (DEVICEIMPL*)device->internal; ZeroMemory(&ctos,sizeof(COMMTIMEOUTS)); ctos.WriteTotalTimeoutConstant = pImpl->timeout; SetCommTimeouts(device->writeFD, &ctos); WriteFile(device->writeFD, sendBuffer, 65, &bytesWritten, NULL);#endif usbDevice->sendBufferWritePtr = usbDevice->sendBuffer;end: if(lockSendBuffer) LeaveCriticalSection(&usbDevice->sendBufferMutex);}
开发者ID:JaegarSarauer,项目名称:DCOMM-Assign2,代码行数:58,
示例12: SetLastErrorbool AdbIOCompletion::IsCompleted() { SetLastError(NO_ERROR); if (!IsOpened()) { SetLastError(ERROR_INVALID_HANDLE); return true; } return HasOverlappedIoCompleted(overlapped()) ? true : false;}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:9,
示例13: wince_handle_eventsstatic int wince_handle_events( struct libusb_context *ctx, struct pollfd *fds, POLL_NFDS_TYPE nfds, int num_ready){ struct wince_transfer_priv* transfer_priv = NULL; POLL_NFDS_TYPE i = 0; BOOL found = FALSE; struct usbi_transfer *transfer; DWORD io_size, io_result; int r = LIBUSB_SUCCESS; usbi_mutex_lock(&ctx->open_devs_lock); for (i = 0; i < nfds && num_ready > 0; i++) { usbi_dbg("checking fd %d with revents = %04x", fds[i].fd, fds[i].revents); if (!fds[i].revents) continue; num_ready--; // Because a Windows OVERLAPPED is used for poll emulation, // a pollable fd is created and stored with each transfer usbi_mutex_lock(&ctx->flying_transfers_lock); list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) { transfer_priv = usbi_transfer_get_os_priv(transfer); if (transfer_priv->pollable_fd.fd == fds[i].fd) { found = TRUE; break; } } usbi_mutex_unlock(&ctx->flying_transfers_lock); if (found && HasOverlappedIoCompleted(transfer_priv->pollable_fd.overlapped)) { io_result = (DWORD)transfer_priv->pollable_fd.overlapped->Internal; io_size = (DWORD)transfer_priv->pollable_fd.overlapped->InternalHigh; usbi_remove_pollfd(ctx, transfer_priv->pollable_fd.fd); // let handle_callback free the event using the transfer wfd // If you don't use the transfer wfd, you run a risk of trying to free a // newly allocated wfd that took the place of the one from the transfer. wince_handle_callback(transfer, io_result, io_size); } else if (found) { usbi_err(ctx, "matching transfer for fd %d has not completed", fds[i]); r = LIBUSB_ERROR_OTHER; break; } else { usbi_err(ctx, "could not find a matching transfer for fd %d", fds[i]); r = LIBUSB_ERROR_NOT_FOUND; break; } } usbi_mutex_unlock(&ctx->open_devs_lock); return r;}
开发者ID:DangB,项目名称:LaunchpadLibUSB,代码行数:55,
示例14: OSFileHasChangedBOOL STDCALL OSFileHasChanged (OSFileChangeData *data){ BOOL hasModified = FALSE; if(HasOverlappedIoCompleted(&data->directoryChange)) { FILE_NOTIFY_INFORMATION *notify = (FILE_NOTIFY_INFORMATION*)data->changeBuffer; for (;;) { if (notify->Action != FILE_ACTION_RENAMED_OLD_NAME && notify->Action != FILE_ACTION_REMOVED) { String strFileName; strFileName.SetLength(notify->FileNameLength); scpy_n(strFileName, notify->FileName, notify->FileNameLength/2); strFileName.KillSpaces(); String strFileChanged; strFileChanged << data->strDirectory << strFileName; if(strFileChanged.CompareI(data->targetFileName)) { hasModified = TRUE; break; } } if (!notify->NextEntryOffset) break; notify = (FILE_NOTIFY_INFORMATION*)((BYTE *)notify + notify->NextEntryOffset); } CloseHandle (data->directoryChange.hEvent); DWORD test; zero(&data->directoryChange, sizeof(data->directoryChange)); zero(data->changeBuffer, sizeof(data->changeBuffer)); data->directoryChange.hEvent = CreateEvent (NULL, TRUE, FALSE, NULL); if(ReadDirectoryChangesW(data->hDirectory, data->changeBuffer, 2048, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE, &test, &data->directoryChange, NULL)) { } else { CloseHandle(data->directoryChange.hEvent); CloseHandle(data->hDirectory); return hasModified; } } return hasModified;}
开发者ID:tks2103,项目名称:OBS,代码行数:54,
示例15: AcceptCircuitryBOOL CNeighbour::AcceptCircuitry(){ if ( m_hPipe == INVALID_HANDLE_VALUE ) return Connect( Settings.Centric.Local ); if ( ! HasOverlappedIoCompleted( &m_pOverlapped ) ) return TRUE; SetChannel( new CCircuitry( m_hPipe ) ); m_hPipe = INVALID_HANDLE_VALUE; return TRUE;}
开发者ID:pics860,项目名称:callcenter,代码行数:11,
示例16: OSMonitorFileDestroyVOID STDCALL OSMonitorFileDestroy (OSFileChangeData *data){ if(!HasOverlappedIoCompleted(&data->directoryChange)) { CancelIoEx(data->hDirectory, &data->directoryChange); WaitForSingleObject(data->directoryChange.hEvent, INFINITE); } CloseHandle(data->directoryChange.hEvent); CloseHandle(data->hDirectory); Free(data);}
开发者ID:tks2103,项目名称:OBS,代码行数:12,
示例17: win32_aio_cancelstatic void win32_aio_cancel(BlockDriverAIOCB *blockacb){ QEMUWin32AIOCB *waiocb = (QEMUWin32AIOCB *)blockacb; /* * CancelIoEx is only supported in Vista and newer. For now, just * wait for completion. */ while (!HasOverlappedIoCompleted(&waiocb->ov)) { aio_poll(bdrv_get_aio_context(blockacb->bs), true); }}
开发者ID:Acidburn0zzz,项目名称:qemu,代码行数:12,
示例18: lockerint TFileAioWriter::write(const char *data, int length){ QMutexLocker locker(&d->mutex); if (!isOpen()) { return -1; } // check whether last writing is finished if (d->syncBuffer.count() > 0) { aiobuf_t *lastab = d->syncBuffer.last(); if (HasOverlappedIoCompleted(&lastab->aio_overlap)) { d->clearSyncBuffer(); } } if (length <= 0) return -1; int len = length; if (data[length - 1] == '/n') { ++len; } aiobuf_t *ab = new aiobuf_t; memset(ab, 0, sizeof(aiobuf_t)); ab->aio_nbytes = len; ab->aio_buf = new char[len]; ab->aio_overlap.Offset = 0xFFFFFFFF; ab->aio_overlap.OffsetHigh = 0xFFFFFFFF; memcpy((void *)ab->aio_buf, data, length); // the last char only LF -> CRLF if (len != length) { ab->aio_buf[len - 2] = '/r'; ab->aio_buf[len - 1] = '/n'; } WriteFile(d->fileHandle, ab->aio_buf, (DWORD)len, NULL, &ab->aio_overlap); if (GetLastError() != ERROR_IO_PENDING) { //fprintf(stderr, "WriteFile error str: %s/n", data); delete (char *)ab->aio_buf; delete ab; close(); return -1; } d->syncBuffer << ab; return 0;}
开发者ID:skipbit,项目名称:treefrog-framework,代码行数:52,
示例19: WaitForSingleObjectFileMon::~FileMon() {#ifdef WIN32 for(auto i : mWatches) { WatchStruct* pWatch=i.second; DWORD dwWaitResult = WaitForSingleObject(ghMutex,INFINITE); while(true) { if(dwWaitResult==WAIT_OBJECT_0) { pWatch->mStopNow = TRUE; if(!ReleaseMutex(ghMutex)) { std::cout << "FileMon : Release mutex err./n"; } break; } else if(dwWaitResult==WAIT_ABANDONED) { break; } } CancelIo(pWatch->mDirHandle); ReadDirectoryChangesW( pWatch->mDirHandle,pWatch->mBuffer,sizeof(pWatch->mBuffer),FALSE, pWatch->mNotifyFilter,NULL,&pWatch->mOverlapped,0); if(!HasOverlappedIoCompleted(&pWatch->mOverlapped)) { SleepEx(5,TRUE); } CloseHandle(pWatch->mOverlapped.hEvent); CloseHandle(pWatch->mDirHandle); HeapFree(GetProcessHeap(),0,pWatch); } CloseHandle(ghMutex);#endif#ifdef LINUX if(notify) { for(auto i : watchMap) { inotify_rm_watch(notify,i.first); //unnecessary because of close below? } } if(notify) { close(notify); }#endif}
开发者ID:archer1357,项目名称:Deferred-Renderer,代码行数:51,
示例20: assertint CSerialController::readNonblock(unsigned char* buffer, unsigned int length){ assert(m_handle != INVALID_HANDLE_VALUE); assert(buffer != NULL); if (length > BUFFER_LENGTH) length = BUFFER_LENGTH; if (m_readPending && length != m_readLength) { ::CancelIo(m_handle); m_readPending = false; } m_readLength = length; if (length == 0U) return 0; if (!m_readPending) { DWORD bytes = 0UL; BOOL res = ::ReadFile(m_handle, m_readBuffer, m_readLength, &bytes, &m_readOverlapped); if (res) { ::memcpy(buffer, m_readBuffer, bytes); return int(bytes); } DWORD error = ::GetLastError(); if (error != ERROR_IO_PENDING) { ::fprintf(stderr, "Error from ReadFile: %04lx/n", error); return -1; } m_readPending = true; } BOOL res = HasOverlappedIoCompleted(&m_readOverlapped); if (!res) return 0; DWORD bytes = 0UL; res = ::GetOverlappedResult(m_handle, &m_readOverlapped, &bytes, TRUE); if (!res) { ::fprintf(stderr, "Error from GetOverlappedResult (ReadFile): %04lx/n", ::GetLastError()); return -1; } ::memcpy(buffer, m_readBuffer, bytes); m_readPending = false; return int(bytes);}
开发者ID:g4klx,项目名称:MMDVMCal,代码行数:51,
示例21: OVERLAPPEDvoid FileWatcherWin32::run(){ if ( mHandles.empty() ) { return; } do { if ( !mHandles.empty() ) { mWatchesLock.lock(); for ( std::size_t i = 0; i < mWatches.size(); i++ ) { WatcherStructWin32 * watch = mWatches[ i ]; // If the overlapped struct was cancelled ( because the creator thread doesn't exists anymore ), // we recreate the overlapped in the current thread and refresh the watch if ( /*STATUS_CANCELED*/0xC0000120 == watch->Overlapped.Internal ) { watch->Overlapped = OVERLAPPED(); RefreshWatch(watch); } // First ensure that the handle is the same, this means that the watch was not removed. if ( HasOverlappedIoCompleted( &watch->Overlapped ) && mHandles[ i ] == watch->Watch->DirHandle ) { DWORD bytes; if ( GetOverlappedResult( watch->Watch->DirHandle, &watch->Overlapped, &bytes, FALSE ) ) { WatchCallback( ERROR_SUCCESS, bytes, &watch->Overlapped ); } } } mWatchesLock.unlock(); if ( mInitOK ) { System::sleep( 10 ); } } else { // Wait for a new handle to be added System::sleep( 10 ); } } while ( mInitOK );}
开发者ID:gbottesi,项目名称:efsw,代码行数:51,
示例22: Overlapped_deallocstatic voidOverlapped_dealloc(OverlappedObject *self){ DWORD bytes; DWORD olderr = GetLastError(); BOOL wait = FALSE; BOOL ret; if (!HasOverlappedIoCompleted(&self->overlapped) && self->type != TYPE_NOT_STARTED) { if (Py_CancelIoEx && Py_CancelIoEx(self->handle, &self->overlapped)) wait = TRUE; Py_BEGIN_ALLOW_THREADS ret = GetOverlappedResult(self->handle, &self->overlapped, &bytes, wait); Py_END_ALLOW_THREADS switch (ret ? ERROR_SUCCESS : GetLastError()) { case ERROR_SUCCESS: case ERROR_NOT_FOUND: case ERROR_OPERATION_ABORTED: break; default: PyErr_Format( PyExc_RuntimeError, "%R still has pending operation at " "deallocation, the process may crash", self); PyErr_WriteUnraisable(NULL); } } if (self->overlapped.hEvent != NULL) CloseHandle(self->overlapped.hEvent); switch (self->type) { case TYPE_READ: case TYPE_ACCEPT: Py_CLEAR(self->allocated_buffer); break; case TYPE_WRITE: case TYPE_READINTO: if (self->user_buffer.obj) PyBuffer_Release(&self->user_buffer); break; } PyObject_Del(self); SetLastError(olderr);}
开发者ID:Dongese,项目名称:cpython,代码行数:50,
示例23: registerCompletionRoutine ~WatchInfo() { if(m_handle != INVALID_HANDLE_VALUE) { m_isStopping = true; ::CancelIo(m_handle); registerCompletionRoutine(false); if(!HasOverlappedIoCompleted(&m_overlapped)) { ::SleepEx(1, TRUE); } ::CloseHandle(m_overlapped.hEvent); ::CloseHandle(m_handle); } }
开发者ID:napina,项目名称:fileos,代码行数:16,
示例24: win32_directory_monitor_destroy_record void win32_directory_monitor_destroy_record(DirectoryMonitorRecord* record) { // This is invoked because it forces all completion notifications // to happen one last time. CancelIo(record->handle); // Wait for i/o operations to finish up. if (!HasOverlappedIoCompleted(&record->async_data)) { SleepEx(5, TRUE); } MEMORY2_DEALLOC(_monitor_state->allocator, record->buffer); CloseHandle(record->handle); MEMORY2_DELETE(_monitor_state->allocator, record); }
开发者ID:apetrone,项目名称:gemini,代码行数:16,
示例25: Overlapped_cancelstatic PyObject *Overlapped_cancel(OverlappedObject *self){ BOOL ret = TRUE; if (self->type == TYPE_NOT_STARTED || self->type == TYPE_WAIT_NAMED_PIPE_AND_CONNECT) Py_RETURN_NONE; if (!HasOverlappedIoCompleted(&self->overlapped)) { Py_BEGIN_ALLOW_THREADS if (Py_CancelIoEx) ret = Py_CancelIoEx(self->handle, &self->overlapped); else ret = CancelIo(self->handle); Py_END_ALLOW_THREADS }
开发者ID:ARK4579,项目名称:cpython,代码行数:17,
示例26: cs////////////////////////////////////////////////////////////////////////////////// // FUNCTION: CIOCPServer::RemoveStaleClient// // DESCRIPTION: Client has died on us, close socket and remove context from our list// // INPUTS: // // NOTES: // // MODIFICATIONS:// // Name Date Version Comments// N T ALMOND 06042001 1.0 Origin// ////////////////////////////////////////////////////////////////////////////////void CIOCPServer::RemoveStaleClient(ClientContext* pContext, BOOL bGraceful){ CLock cs(m_cs, "RemoveStaleClient"); TRACE("CIOCPServer::RemoveStaleClient/n"); LINGER lingerStruct; // // If we're supposed to abort the connection, set the linger value // on the socket to 0. // if ( !bGraceful ) { lingerStruct.l_onoff = 1; lingerStruct.l_linger = 0; setsockopt( pContext->m_Socket, SOL_SOCKET, SO_LINGER, (char *)&lingerStruct, sizeof(lingerStruct) ); } // // Free context structures if (m_listContexts.Find(pContext)) { // // Now close the socket handle. This will do an abortive or graceful close, as requested. CancelIo((HANDLE) pContext->m_Socket); closesocket( pContext->m_Socket ); pContext->m_Socket = INVALID_SOCKET; while (!HasOverlappedIoCompleted((LPOVERLAPPED)pContext)) Sleep(0); m_pNotifyProc((LPVOID) m_pFrame, pContext, NC_CLIENT_DISCONNECT); MoveToFreePool(pContext); }}
开发者ID:8ackl0,项目名称:remotectrl,代码行数:62,
示例27: RCX_sendint RCX_send(unsigned char *message, int length){ //sends a message to the RCX //returns 1 if write succeeded, 0 if failed //maximal length of message is 125 bytes int i; unsigned long res,ptr; int s=0; //create message to send sendbuf[0]=0x55; sendbuf[1]=0xff; sendbuf[2]=0x00; ptr=3; for (i=0; i<length; i++){ sendbuf[ptr++]=message[i]; sendbuf[ptr++]=message[i]^0xff; s+=message[i]; } sendbuf[ptr++]=(unsigned char)s; sendbuf[ptr++]=((unsigned char)s)^0xff; res=0; ovl.Offset=0; ovl.OffsetHigh=0; ovl.hEvent=NULL; if(!WriteFile(RCX_port,sendbuf,ptr,&res,&ovl)){ if (GetLastError()==ERROR_IO_PENDING){ i=0; do{ Sleep(10); i++; } while ((!HasOverlappedIoCompleted(&ovl))&&(i<50)); if (i<50){ return(1); //completed. } else { CancelIo(RCX_port); //cancel transmission. return(0); //not completed. } } else { //some error occured CancelIo(RCX_port); //cancel transmission. return(0); } } return(1);}
开发者ID:rkovessy,项目名称:VeWalker,代码行数:45,
示例28: CheckPipeConnectionstatic bool CheckPipeConnection(HANDLE hPipe, HANDLE hEvent, OVERLAPPED *pOl, bool *pbWait){ if (!*pbWait) { ::ZeroMemory(pOl, sizeof(OVERLAPPED)); pOl->hEvent = hEvent; if (!::ConnectNamedPipe(hPipe, pOl)) { // すでに接 C++ HasShadowManager函数代码示例 C++ HasLowerSecurity函数代码示例
|