Esempio n. 1
0
Io_Manager Io_Manager__init() {
    // Initialize an event manager, and allocate an I/O completion port.
    Coroutine__set_signals(); 
    
    Io_Manager ret = Boot_calloc(sizeof(struct Io_Manager));
#ifdef WINDOWS
    WORD version = MAKEWORD(2, 2);
    WSADATA data;
    // Disable error dialog boxes
    SetErrorMode(GetErrorMode()|SEM_NOGPFAULTERRORBOX); 
    if (WSAStartup(version, &data) != 0) {
        Boot_abort();
    }
#endif
    ret->_vtable = Io_Manager__vtable;
    ret->_refcount = 1;
    ret->scheduled = Queue__init(0);
    ret->waiting = 0;
#if defined(WINDOWS)
    ret->handle = (Int)CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0);
#elif defined(DARWIN)
    ret->handle = (Int)kqueue();
#elif defined(LINUX)
    ret->handle = (Int)epoll_create(1);
#endif
    return ret;
}
Esempio n. 2
0
void init()
{
	Queue__init(q);

}