当前位置: 首页>>代码示例>>C++>>正文


C++ HasOverlappedIoCompleted函数代码示例

本文整理汇总了C++中HasOverlappedIoCompleted函数的典型用法代码示例。如果您正苦于以下问题:C++ HasOverlappedIoCompleted函数的具体用法?C++ HasOverlappedIoCompleted怎么用?C++ HasOverlappedIoCompleted使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HasOverlappedIoCompleted函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lock

DWORD 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,代码来源:egtcpdriver.cpp

示例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,代码来源:FileWatcher.cpp

示例3: pLock

BOOL 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,代码来源:Circuitry.cpp

示例4: eof_timer_cb

static 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,代码来源:pipe.c

示例5: RecordWith

int 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,代码来源:Circuitry.cpp

示例6: gry_check

// pb with this code: works if no receiving of chars has been previously done
static 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,代码来源:link_gry2.c

示例7: gry_get

static 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,代码来源:link_gry2.c

示例8: gry_put

static 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,代码来源:link_gry2.c

示例9: RCX_receive

int 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,代码来源:rcx21.cpp

示例10: HasOverlappedIoCompleted

bool File::HasAsyncIOCompleted()
{
#if _WIN32 || _WIN64
	return HasOverlappedIoCompleted( &m_overlapped );
#else
	return false;
#endif
}
开发者ID:nsweb,项目名称:bigball,代码行数:8,代码来源:file.cpp

示例11: USBDevice_internalFlush

void 
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,代码来源:USBDevice.c

示例12: SetLastError

bool 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,代码来源:adb_io_completion.cpp

示例13: wince_handle_events

static 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,代码来源:wince_usb.c

示例14: OSFileHasChanged

BOOL 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,代码来源:XT_Windows.cpp

示例15: AcceptCircuitry

BOOL 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,代码来源:Neighbour.cpp


注:本文中的HasOverlappedIoCompleted函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。