當前位置: 首頁>>代碼示例>>C++>>正文


C++ CancelIo函數代碼示例

本文整理匯總了C++中CancelIo函數的典型用法代碼示例。如果您正苦於以下問題:C++ CancelIo函數的具體用法?C++ CancelIo怎麽用?C++ CancelIo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CancelIo函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: native_dirmonitor_remove

void native_dirmonitor_remove(Ref *r)
{
    FileMonitor *fm = Value_ptr(r->v[INDEX_FILEMONITOR_STRUCT]);

    if (fm != NULL) {
        fm->valid = FALSE;
        CancelIo(fm->hDir);
        refresh_dirmonitor(fm, TRUE);

        if (!HasOverlappedIoCompleted(&fm->overlapped)) {
            SleepEx(5, TRUE);
        }
        CloseHandle(fm->hDir);
        CloseHandle(fm->overlapped.hEvent);

        FileMonitor_del(fm);
        r->v[INDEX_FILEMONITOR_STRUCT] = VALUE_NULL;
    }
}
開發者ID:x768,項目名稱:fox-lang,代碼行數:19,代碼來源:monitor.c

示例2: ser_read_internal

static u32 ser_read_internal( ser_handler id, u32 timeout )
{
    HANDLE hComm = id->hnd;
    DWORD readbytes = 0;
    DWORD dwRes = WaitForSingleObject( id->o.hEvent, timeout == SER_INF_TIMEOUT ? INFINITE : timeout );
    if( dwRes == WAIT_OBJECT_0 )
    {
        if( !GetOverlappedResult( hComm, &id->o, &readbytes, TRUE ) )
            readbytes = 0;
    }
    else if( dwRes == WAIT_TIMEOUT )
    {
        CancelIo( hComm );
        GetOverlappedResult( hComm, &id->o, &readbytes, TRUE );
        readbytes = 0;
    }
    ResetEvent( id->o.hEvent );
    return readbytes;
}
開發者ID:Theemuts,項目名稱:eLuaBrain,代碼行數:19,代碼來源:serial_win32.c

示例3: cancel_io

static __inline BOOL cancel_io(int _index)
{
	if ((_index < 0) || (_index >= MAX_FDS)) {
		return FALSE;
	}

	if ( (poll_fd[_index].fd < 0) || (poll_fd[_index].handle == INVALID_HANDLE_VALUE)
	  || (poll_fd[_index].handle == 0) || (poll_fd[_index].overlapped == NULL) ) {
		return TRUE;
	}
	if (CancelIoEx_Available) {
		return (*pCancelIoEx)(poll_fd[_index].handle, poll_fd[_index].overlapped);
	}
	if (_poll_fd[_index].thread_id == GetCurrentThreadId()) {
		return CancelIo(poll_fd[_index].handle);
	}
	usbi_warn(NULL, "Unable to cancel I/O that was started from another thread");
	return FALSE;
}
開發者ID:qtekfun,項目名稱:htcDesire820Kernel,代碼行數:19,代碼來源:poll_windows.c

示例4: ser_windows_close

static void
ser_windows_close (struct serial *scb)
{
  struct ser_windows_state *state;

  /* Stop any pending selects.  */
  CancelIo ((HANDLE) _get_osfhandle (scb->fd));
  state = scb->state;
  CloseHandle (state->ov.hEvent);
  CloseHandle (state->except_event);

  if (scb->fd < 0)
    return;

  close (scb->fd);
  scb->fd = -1;

  xfree (scb->state);
}
開發者ID:3125788,項目名稱:android_toolchain_gdb,代碼行數:19,代碼來源:ser-mingw.c

示例5: CancelIo

VOID CFileMonitorRequest::StopCheck( ULONG_PTR aRequest )
{
    CFileMonitorRequest * req = (CFileMonitorRequest *)aRequest;
    if ( INVALID_HANDLE_VALUE != req->m_hMonitorPath )
    {
        CancelIo( req->m_hMonitorPath );
        for ( int i = 0 ; i < MONITOR_THREAD_STOP_MAX_RETRY_COUNT ; i++ )
        {
            if ( TRUE == HasOverlappedIoCompleted(&req->m_overlapped) )
                break;
            else
                SleepEx( 100 , TRUE );
        }        
        CloseHandle( req->m_hMonitorPath );
        req->m_hMonitorPath = INVALID_HANDLE_VALUE;

        req->DecrementWorkCount( req->m_parent );
    }
}
開發者ID:winest,項目名稱:CWUtils,代碼行數:19,代碼來源:CWFileMonitor.cpp

示例6: switch

bool SerialPort::event(QEvent *e)
{
    if (e->type() != QEvent::User)
        return QObject::event(e);
    switch (static_cast<SerialEvent*>(e)->reason()){
    case EventComplete:{
            DWORD bytes;
            if (GetOverlappedResult(d->hPort, &d->over, &bytes, true)){
                if (d->m_state == Read){
                    d->m_buff.pack(&d->m_char, 1);
                    if (d->m_char == '\n')
                        emit read_ready();
                }
                if (d->m_state == Write){
                    emit write_ready();
                    d->m_state = Read;
                }
                if (d->m_state == Read){
                    d->m_state = StartRead;
                    SetEvent(d->hEvent);
                }
                break;
            }
            close();
            emit error();
            break;
        }
    case EventTimeout:{
            log(L_WARN, "IO timeout");
            CancelIo(d->hPort);
            close();
            emit error();
            break;
        }
    case EventError:{
            log(L_WARN, "IO error");
            close();
            emit error();
        }
    }
    return true;
}
開發者ID:BackupTheBerlios,項目名稱:sim-im-svn,代碼行數:42,代碼來源:serial.cpp

示例7: open_device

static HANDLE open_device(const char *path, BOOL enumerate)
{
	HANDLE handle;
	DWORD desired_access = (enumerate)? 0: (GENERIC_WRITE | GENERIC_READ);
	DWORD share_mode = (enumerate)?
	                      FILE_SHARE_READ|FILE_SHARE_WRITE:
	                      FILE_SHARE_READ;

	handle = CreateFileA(path,
		desired_access,
		share_mode,
		NULL,
		OPEN_EXISTING,
		FILE_FLAG_OVERLAPPED,/*FILE_ATTRIBUTE_NORMAL,*/
		0);

  CancelIo(handle);

	return handle;
}
開發者ID:ByteArts,項目名稱:picflash,代碼行數:20,代碼來源:hid-win.c

示例8: error

void SerialPort::writeLine(const char *data, unsigned read_time)
{
    if (d->hPort == INVALID_HANDLE_VALUE){
        emit error();
        return;
    }
    switch (d->m_state){
    case Read:
    case Write:
        CancelIo(d->hPort);
        break;
    default:
        break;
    }
    d->m_state		= StartWrite;
    d->m_line		= data;
    d->m_read_time	= read_time;
    FlushFileBuffers(d->hPort);
    SetEvent(d->hEvent);
}
開發者ID:BackupTheBerlios,項目名稱:sim-im-svn,代碼行數:20,代碼來源:serial.cpp

示例9: win32iocp_cancel

static void
win32iocp_cancel (struct event *ev, unsigned int rw_flags)
{
    if (!pCancelIoEx) {
	CancelIo(ev->fd);
	rw_flags = (EVENT_READ | EVENT_WRITE);
    }
    if ((rw_flags & EVENT_READ) && ev->w.iocp.rov) {
	if (pCancelIoEx) pCancelIoEx(ev->fd, (OVERLAPPED *) ev->w.iocp.rov);
	ev->w.iocp.rov->ev = NULL;
	ev->w.iocp.rov = NULL;
	ev->flags &= ~EVENT_RPENDING;
    }
    if ((rw_flags & EVENT_WRITE) && ev->w.iocp.wov) {
	if (pCancelIoEx) pCancelIoEx(ev->fd, (OVERLAPPED *) ev->w.iocp.wov);
	ev->w.iocp.wov->ev = NULL;
	ev->w.iocp.wov = NULL;
	ev->flags &= ~EVENT_WPENDING;
    }
}
開發者ID:dilshod,項目名稱:luasys,代碼行數:20,代碼來源:win32iocp.c

示例10: lock

/*!
Closes a serial port.  This function has no effect if the serial port associated with the class
is not currently open.
*/
void QextSerialPort::close()
{
    QMutexLocker lock(mutex);
    if (isOpen()) {
        flush();
        QIODevice::close(); // mark ourselves as closed
        CancelIo(Win_Handle);
        if (CloseHandle(Win_Handle))
            Win_Handle = INVALID_HANDLE_VALUE;
        if (winEventNotifier)
            winEventNotifier->deleteLater();

        _bytesToWrite = 0;

        foreach(OVERLAPPED* o, pendingWrites) {
            CloseHandle(o->hEvent);
            delete o;
        }
        pendingWrites.clear();
    }
開發者ID:M-Elfeki,項目名稱:Auto_Pilot,代碼行數:24,代碼來源:win_qextserialport.cpp

示例11: FinishCommand

// Returns errcode (or 0 if successful)
DWORD FinishCommand(BOOL boolresult)
{
	DWORD errcode;
	DWORD waitcode;

#ifdef VERBOSE_FUNCTION_DEVICE
	PrintLog("CDVDiso device: FinishCommand()");
#endif /* VERBOSE_FUNCTION_DEVICE */

	if (boolresult == TRUE)
	{
		ResetEvent(waitevent.hEvent);
		return(0);
	} // ENDIF- Device is ready? Say so.

	errcode = GetLastError();
	if (errcode == ERROR_IO_PENDING)
	{
#ifdef VERBOSE_FUNCTION_DEVICE
		PrintLog("CDVDiso device:   Waiting for completion.");
#endif /* VERBOSE_FUNCTION_DEVICE */
		waitcode = WaitForSingleObject(waitevent.hEvent, 10 * 1000); // 10 sec wait
		if ((waitcode == WAIT_FAILED) || (waitcode == WAIT_ABANDONED))
		{
			errcode = GetLastError();
		}
		else if (waitcode == WAIT_TIMEOUT)
		{
			errcode = 21;
			CancelIo(devicehandle); // Speculative Line
		}
		else
		{
			ResetEvent(waitevent.hEvent);
			return(0); // Success!
		} // ENDIF- Trouble waiting? (Or doesn't finish in 5 seconds?)
	} // ENDIF- Should we wait for the call to finish?

	ResetEvent(waitevent.hEvent);
	return(errcode);
} // END DeviceCommand()
開發者ID:ACanadianKernel,項目名稱:pcsx2,代碼行數:42,代碼來源:device.c

示例12: pipe_disconnect

/*
 * Disconnect, but do not close, a pipe handle; and deregister
 * any pending waiter threads from its event handles.
 *
 * XXX: This must be called from primary thread, or lock held if not!
 */
void
pipe_disconnect(pipe_instance_t *pp)
{

    TRACE0(ENTER, "Entering pipe_disconnect");

    if (pp == NULL)
	return;
    /*
     * Cancel pending I/O before deregistering the callback,
     * and disconnect the pipe, to avoid race conditions.
     * We also reset the event(s) to avoid being signalled for
     * things which haven't actually happened yet.
     *
     * XXX: To avoid races during shutdown, we may have to
     * NULL out the second argument to UnregisterWaitEx().
     * We can't, however, do that from a service thread.
     */
    if (pp->cwait != NULL) {
        UnregisterWaitEx(pp->cwait, pp->cevent);
	ResetEvent(pp->cevent);
	pp->cwait = NULL;
    }
    if (pp->rwait != NULL) {
        UnregisterWaitEx(pp->rwait, pp->revent);
	ResetEvent(pp->revent);
	pp->rwait = NULL;
    }

    if (pp->pipe != NULL) {
        CancelIo(pp->pipe);
	if (pp->state == PIPE_STATE_CONNECTED ||
	    pp->state == PIPE_STATE_LISTEN) {
	    DisconnectNamedPipe(pp->pipe);
	}
    }

    pp->state = PIPE_STATE_INIT;

    TRACE0(ENTER, "Leaving pipe_disconnect");
}
開發者ID:BillTheBest,項目名稱:xorp.ct,代碼行數:47,代碼來源:xorprtm.c

示例13: IOProcessorUnregisterSocket

// put back the IODesc to the free list and cancel all IO and put back FD
bool IOProcessorUnregisterSocket(FD& fd)
{
	IODesc*		iod;
	BOOL		ret;

	Log_Trace("fd = %d", fd.index);

	iod = &iods[fd.index];
	iod->next = freeIods;
	freeIods = iod;

	ret = CancelIo((HANDLE)fd.sock);
	if (ret == 0)
	{
		ret = WSAGetLastError();
		Log_Trace("CancelIo error %d", ret);
		return false;
	}

	return true;
}
開發者ID:agazso,項目名稱:keyspace,代碼行數:22,代碼來源:IOProcessor_Windows.cpp

示例14: defined

void Socket::CloseSocket()
{
	if (m_s != INVALID_SOCKET)
	{
#ifdef USE_WINDOWS_STYLE_SOCKETS
# if defined(USE_WINDOWS8_API)
		BOOL result = CancelIoEx((HANDLE) m_s, NULL);
		assert(result || (!result && GetLastError() == ERROR_NOT_FOUND));
		CheckAndHandleError_int("closesocket", closesocket(m_s));
# else
		BOOL result = CancelIo((HANDLE) m_s);
		assert(result || (!result && GetLastError() == ERROR_NOT_FOUND));
		CheckAndHandleError_int("closesocket", closesocket(m_s));
# endif
#else
		CheckAndHandleError_int("close", close(m_s));
#endif
		m_s = INVALID_SOCKET;
		SocketChanged();
	}
}
開發者ID:Tad-Done,項目名稱:cryptopp,代碼行數:21,代碼來源:socketft.cpp

示例15: DestroyWatch

    /// Stops monitoring a directory.
    void DestroyWatch(WatchStruct* pWatch)
    {
        if (pWatch)
        {
            pWatch->mStopNow = TRUE;

            CancelIo(pWatch->mDirHandle);

            RefreshWatch(pWatch, true);

            if (!HasOverlappedIoCompleted(&pWatch->mOverlapped))
            {
                SleepEx(5, TRUE);
            }

            CloseHandle(pWatch->mOverlapped.hEvent);
            CloseHandle(pWatch->mDirHandle);
            delete pWatch->mDirName;
            HeapFree(GetProcessHeap(), 0, pWatch);
        }
    }
開發者ID:Nelarius,項目名稱:filesentry,代碼行數:22,代碼來源:FileWatcherWin32.cpp


注:本文中的CancelIo函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。