office-gobmx/sal/osl/w32/conditn.c

144 lines
4.8 KiB
C
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 09:18:43 -05:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 09:18:43 -05:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 09:18:43 -05:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 09:18:43 -05:00
*
* This file is part of OpenOffice.org.
2000-09-18 09:18:43 -05:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 09:18:43 -05:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 09:18:43 -05:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 09:18:43 -05:00
*
************************************************************************/
#include "system.h"
#include <osl/conditn.h>
#include <osl/diagnose.h>
2001-03-14 02:50:26 -06:00
#include <osl/time.h>
2000-09-18 09:18:43 -05:00
/*
under WIN32, we use the void* oslCondition
as a WIN32 HANDLE (which is also a 32-bit value)
*/
/*****************************************************************************/
/* osl_createCondition */
/*****************************************************************************/
oslCondition SAL_CALL osl_createCondition(void)
2000-09-18 09:18:43 -05:00
{
oslCondition Condition;
Condition= (oslCondition)CreateEvent(0, /* no security */
sal_True, /* manual reset */
sal_False, /* initial state not signaled */
0); /* automatic name */
return Condition;
}
/*****************************************************************************/
/* osl_destroyCondition */
/*****************************************************************************/
void SAL_CALL osl_destroyCondition(oslCondition Condition)
{
if(Condition)
{
OSL_VERIFY(CloseHandle(Condition));
}
}
/*****************************************************************************/
/* osl_setCondition */
/*****************************************************************************/
sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
{
OSL_ASSERT(Condition);
return (sal_Bool)(SetEvent((HANDLE)Condition) != FALSE);
2000-09-18 09:18:43 -05:00
}
/*****************************************************************************/
/* osl_resetCondition */
/*****************************************************************************/
sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
{
OSL_ASSERT(Condition);
return (sal_Bool)(ResetEvent((HANDLE)Condition) != FALSE);
2000-09-18 09:18:43 -05:00
}
/*****************************************************************************/
/* osl_waitCondition */
/*****************************************************************************/
oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition,
const TimeValue* pTimeout)
{
DWORD timeout;
OSL_ASSERT(Condition);
if (pTimeout)
timeout = pTimeout->Seconds * 1000 + pTimeout->Nanosec / 1000000L;
else
timeout = INFINITE;
/* It's necessary to process SendMessage calls to the current thread to give other threads
access to COM objects instatiated in this thread */
while ( 1 )
2000-09-18 09:18:43 -05:00
{
/* Only wake up if a SendMessage call to the threads message loop is detected */
CWS-TOOLING: integrate CWS kso32fixes 2009-07-10 15:25:24 +0200 kso r273899 : #i53184# - fix probs with UNC server names containing underscores. 2009-07-10 14:31:59 +0200 kso r273893 : CWS-TOOLING: rebase CWS kso32fixes to trunk@273858 (milestone: DEV300:m52) 2009-07-09 13:46:16 +0200 kso r273861 : #i53184# - withdrew patch. 2009-07-08 13:39:00 +0200 kso r273829 : #i63159# - added license header 2009-07-08 11:44:08 +0200 kso r273824 : i53184 - cannot open files from shell if UNC server has a _ (underscore) 2009-07-08 11:21:12 +0200 kso r273822 : #i93271# - mingw build error 2009-07-08 11:13:48 +0200 kso r273821 : #i91247 - Adhere to one more xdg spec 2009-07-08 11:02:53 +0200 kso r273820 : #i89017# - osl_trace now emits trailing line feed to the debugger 2009-07-08 10:55:04 +0200 kso r273819 : #i88663# - not waiting on successful forks but subsequent process failure 2009-07-07 17:05:27 +0200 kso r273810 : #i88382# - It's nice to leave the modal mode in gtk+ too ;-) 2009-07-07 16:53:34 +0200 kso r273808 : i88331# - Typo in include guard 2009-07-07 16:48:17 +0200 kso r273807 : i82831# - crashrep: warnings when size_t != int 2009-07-07 16:39:49 +0200 kso r273806 : i63159# - Patch to use d_type field in dirent structure if possible 2009-06-24 12:52:27 +0200 kso r273333 : #i100274# - solved win2k missing symbol problem (again). 2009-05-20 13:58:48 +0200 kso r272124 : CWS-TOOLING: rebase CWS kso32fixes to trunk@271830 (milestone: DEV300:m48) 2009-04-17 14:50:54 +0200 kso r270950 : CWS-TOOLING: rebase CWS kso32fixes to trunk@270723 (milestone: DEV300:m46) 2009-03-26 09:27:28 +0100 kso r270054 : #i100274# NTLM code cleanup. 2009-03-20 14:13:38 +0100 kso r269807 : #i100274# - Fixed potential buffer overflow in NTLM code. 2009-03-19 14:53:03 +0100 kso r269748 : #i100274. Added NTLM support for Non-Windows platforms. 2009-03-17 15:52:44 +0100 kso r269613 : CWS-TOOLING: rebase CWS kso32fixes to trunk@269297 (milestone: DEV300:m43)
2009-07-27 10:26:29 -05:00
switch( MsgWaitForMultipleObjects( 1, (HANDLE *)(&Condition), FALSE, timeout, QS_SENDMESSAGE ) )
{
case WAIT_OBJECT_0 + 1:
{
MSG msg;
/* We Must not dispatch the message. PM_NOREMOVE leaves the message queue untouched
but dispatches SendMessage calls automatically */
PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE );
}
break;
case WAIT_OBJECT_0:
return (osl_cond_result_ok);
case WAIT_TIMEOUT:
return (osl_cond_result_timeout);
default:
return (osl_cond_result_error);
}
2000-09-18 09:18:43 -05:00
}
}
/*****************************************************************************/
/* osl_checkCondition */
/*****************************************************************************/
sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition)
{
OSL_ASSERT(Condition);
return (sal_Bool)(WaitForSingleObject((HANDLE)Condition, 0) == WAIT_OBJECT_0);
2000-09-18 09:18:43 -05:00
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */