semevent-win.cpp revision 333e7ab9cd83b32080826d06ac7b1951c684ccb5
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * IPRT - Event Sempahore, Windows.
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * Copyright (C) 2006-2009 Sun Microsystems, Inc.
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * available from http://www.virtualbox.org. This file is free software;
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * you can redistribute it and/or modify it under the terms of the GNU
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * General Public License (GPL) as published by the Free Software
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * The contents of this file may alternatively be used under the terms
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * of the Common Development and Distribution License Version 1.0
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * VirtualBox OSE distribution, in which case the provisions of the
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * CDDL are applicable instead of those of the GPL.
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * You may elect to license modified versions of this file under the
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * terms and conditions of either the GPL or the CDDL or both.
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * additional information or have any questions.
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync/*******************************************************************************
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync* Header Files *
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync*******************************************************************************/
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync/*******************************************************************************
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync* Defined Constants And Macros *
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync*******************************************************************************/
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync/** Converts semaphore to win32 handle. */
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync/* Undefine debug mappings. */
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * Create the semaphore.
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * (Auto reset, not signaled, private event object.)
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync HANDLE hev = CreateEvent(NULL, FALSE, FALSE, NULL);
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * Close semaphore handle.
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync AssertMsgFailed(("Destroy EventSem %p failed, lasterr=%d\n", EventSem, GetLastError()));
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsyncRTDECL(int) RTSemEventWaitNoResume(RTSEMEVENT EventSem, unsigned cMillies)
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * Wait for condition.
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync int rc = WaitForSingleObjectEx(SEM2HND(EventSem), cMillies == RT_INDEFINITE_WAIT ? INFINITE : cMillies, TRUE);
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync AssertMsgFailed(("Wait on EventSem %p failed, rc=%d lasterr=%d\n", EventSem, rc, GetLastError()));
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync AssertMsgFailed(("WaitForSingleObject(event) -> rc=%d while converted lasterr=%d\n", rc, rc2));
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync * Signal the object.
5964f60ed7fb52a3c4becbe83c9429f9b2f119c2vboxsync AssertMsgFailed(("Signaling EventSem %p failed, lasterr=%d\n", EventSem, GetLastError()));
0fcf82b2591711fa8980e8f5d9cad1b8f222d6d7vboxsyncRTDECL(void) RTSemEventSetSignaller(RTSEMEVENT hEventSem, RTTHREAD hThread)
0fcf82b2591711fa8980e8f5d9cad1b8f222d6d7vboxsync/** @todo implement RTSemEventSetSignaller and friends for NT. */
0fcf82b2591711fa8980e8f5d9cad1b8f222d6d7vboxsyncRTDECL(void) RTSemEventAddSignaller(RTSEMEVENT hEventSem, RTTHREAD hThread)