(file) Return to IPCWindows_inline.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

File: [Pegasus] / pegasus / src / Pegasus / Common / Attic / IPCWindows_inline.h (download)
Revision: 1.23, Mon Jan 30 16:17:04 2006 UTC (18 years, 5 months ago) by karl
Branch: MAIN
CVS Tags: TASK_PEP233_EmbeddedInstSupport-merge_out_trunk, TASK_BUG_5191_QUEUE_CONSOLIDATION_ROOT, TASK-PEP250_RPMProvider-root, TASK-PEP250_RPMProvider-merged_out_to_branch, TASK-PEP250_RPMProvider-merged_out_from_trunk, TASK-PEP250_RPMProvider-merged_in_to_trunk, TASK-PEP250_RPMProvider-merged_in_from_branch, TASK-PEP250_RPMProvider-branch, TASK-PEP245_CimErrorInfrastructure-root, TASK-PEP245_CimErrorInfrastructure-merged_out_to_branch, TASK-PEP245_CimErrorInfrastructure-merged_out_from_trunk, TASK-PEP245_CimErrorInfrastructure-merged_in_to_trunk, TASK-PEP245_CimErrorInfrastructure-merged_in_from_branch, TASK-PEP245_CimErrorInfrastructure-branch, TASK-PEP241_OpenPegasusStressTests-root, TASK-PEP241_OpenPegasusStressTests-merged_out_to_branch, TASK-PEP241_OpenPegasusStressTests-merged_out_from_trunk, TASK-PEP241_OpenPegasusStressTests-merged_in_to_trunk, TASK-PEP241_OpenPegasusStressTests-merged_in_from_branch, TASK-PEP241_OpenPegasusStressTests-branch, TASK-BUG4011_WinLocalConnect-root, TASK-BUG4011_WinLocalConnect-merged_out_to_branch, TASK-BUG4011_WinLocalConnect-merged_out_from_trunk, TASK-BUG4011_WinLocalConnect-merged_in_to_trunk, TASK-BUG4011_WinLocalConnect-merged_in_from_branch, TASK-BUG4011_WinLocalConnect-branch, RELEASE_2_5_5-RC2, RELEASE_2_5_5-RC1, RELEASE_2_5_5, RELEASE_2_5_4-RC2, RELEASE_2_5_4-RC1, RELEASE_2_5_4, RELEASE_2_5_3-RC1, RELEASE_2_5_3, RELEASE_2_5_2-RC1, RELEASE_2_5_2, RELEASE_2_5_1-RC1, RELEASE_2_5_1, RELEASE_2_5-root, RELEASE_2_5-branch
Branch point for: TASK_BUG_5191_QUEUE_CONSOLIDATION_BRANCH
Changes since 1.22: +3 -1 lines
BUG#: 4691
TITLE: Update Licenses to 2006

DESCRIPTION: Updates most of the licenses to 2006. The slp_client directories are excluded for the moment pending discussion. This change has passed unit and system tests.  Note that this changes just about EVERY file in Pegasus.

//%2006////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
// IBM Corp.; EMC Corporation, The Open Group.
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
// EMC Corporation; VERITAS Software Corporation; The Open Group.
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
// EMC Corporation; Symantec Corporation; The Open Group.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//==============================================================================
//
// Author: Mike Day (mdday@us.ibm.com)
//
// Modified By: David Dillard, VERITAS Software Corp.
//              (david.dillard@veritas.com)
//
//%/////////////////////////////////////////////////////////////////////////////


//%// ---- inline implmentations of Windows IPC routines ----

#ifndef IPCWindows_inline_h
#define IPCWindows_inline_h

//-----------------------------------------------------------------
/// Native Windows inline implementation of Mutex class
//-----------------------------------------------------------------

// block until gaining the lock - throw a deadlock
// exception if process already holds the lock
inline void Mutex::lock(PEGASUS_THREAD_TYPE caller)
{
    if(_mutex.owner == caller)
        throw( Deadlock( _mutex.owner ) );

    DWORD errorcode = WaitForSingleObject(_mutex.mut, INFINITE);
    if(errorcode == WAIT_FAILED)
        throw( WaitFailed( _mutex.owner) );
    _mutex.owner = caller;
}

// try to gain the lock - lock succeeds immediately if the
// mutex is not already locked. throws an exception and returns
// immediately if the mutex is currently locked.
inline void Mutex::try_lock(PEGASUS_THREAD_TYPE caller)
{
    if(_mutex.owner == caller)
        throw( Deadlock( _mutex.owner ) );

    DWORD errorcode = WaitForSingleObject(_mutex.mut, 0);
    if (errorcode == WAIT_TIMEOUT)
        throw(AlreadyLocked(_mutex.owner));
    if(errorcode == WAIT_FAILED)
        throw(WaitFailed(_mutex.owner));
    _mutex.owner = caller;
}

// wait for milliseconds and throw an exception then return if the wait
// expires without gaining the lock. Otherwise return without throwing an
// exception.

inline void Mutex::timed_lock( Uint32 milliseconds , PEGASUS_THREAD_TYPE caller)
{
    if(_mutex.owner == caller)
        throw( Deadlock( _mutex.owner ) );

    DWORD errorcode = WaitForSingleObject(_mutex.mut, milliseconds);
    if (errorcode == WAIT_TIMEOUT)
        throw(TimeOut(_mutex.owner));
    if(errorcode == WAIT_FAILED)
        throw(WaitFailed(_mutex.owner));
    _mutex.owner = caller;
}

// unlock the mutex
inline void Mutex::unlock()
{
    PEGASUS_THREAD_TYPE m_owner = _mutex.owner;
    _mutex.owner = 0;
    ReleaseMutex(_mutex.mut);
}


//-----------------------------------------------------------------
/// Native Windows inline implementation of Semaphore class
//-----------------------------------------------------------------

// block until this semaphore is in a signalled state
// note that windows does not support interrupt
inline void Semaphore::wait(Boolean ignoreInterrupt)
{
    DWORD errorcode = WaitForSingleObject(_semaphore.sem, INFINITE);
    if(errorcode != WAIT_FAILED)
        _count--;
    else
        throw(WaitFailed((PEGASUS_THREAD_TYPE)GetCurrentThreadId()));
}

// wait succeeds immediately if semaphore has a non-zero count,
// return immediately and throw and exception if the
// count is zero.
inline void Semaphore::try_wait()
{
    DWORD errorcode = WaitForSingleObject(_semaphore.sem, 0);
    if(errorcode == WAIT_TIMEOUT || errorcode == WAIT_FAILED)
        throw(WaitFailed((PEGASUS_THREAD_TYPE)GetCurrentThreadId()));
    _count--;
}


// wait for milliseconds and throw an exception
// if wait times out without gaining the semaphore
inline void Semaphore::time_wait(Uint32 milliseconds)
{
    DWORD errorcode = WaitForSingleObject(_semaphore.sem, milliseconds);
    if (errorcode == WAIT_TIMEOUT || errorcode == WAIT_FAILED)
        throw(TimeOut((PEGASUS_THREAD_TYPE)GetCurrentThreadId()));
    _count--;
}

// increment the count of the semaphore
inline void Semaphore::signal()
{
    _count++;
    ReleaseSemaphore(_semaphore.sem, 1, NULL);
}

// return the count of the semaphore
inline int Semaphore::count() const
{
    return(_count);
}


//_________________________________________________________________
//
/// Native Windows implementation of the conditional semaphore
//_________________________________________________________________

#ifdef PEGASUS_CONDITIONAL_NATIVE

inline void Condition::signal(PEGASUS_THREAD_TYPE caller)
{
    _cond_mutex->lock(caller);
    try
    {
        unlocked_signal(caller);
    }
    catch(...)
    {
        unlock_object();
        throw;
    }
    _cond_mutex->unlock();
}

inline void Condition::unlocked_signal(PEGASUS_THREAD_TYPE caller)
{
    if(_cond_mutex->_mutex.owner != caller)
        throw Permission((PEGASUS_THREAD_TYPE)caller);

    // Change from PulseEvent to SetEvent, this is part of
    //    fix to avoid deadlock in CIMClient Constructor.
    //PulseEvent(_condition);
    SetEvent(_condition);
}

inline void Condition::lock_object(PEGASUS_THREAD_TYPE caller)
{
    if(_disallow.get() > 0 )
        throw ListClosed();
    _cond_mutex->lock(caller);
}

inline void Condition::try_lock_object(PEGASUS_THREAD_TYPE caller)
{
    if(_disallow.get() > 0 )
        throw ListClosed();
    _cond_mutex->try_lock(caller);
}

inline void Condition::wait_lock_object(PEGASUS_THREAD_TYPE caller, int milliseconds)
{
    if(_disallow.get() > 0)
        throw ListClosed();
    _cond_mutex->timed_lock(milliseconds, caller);
    if( _disallow.get() > 0 )
    {
        _cond_mutex->unlock();
        throw ListClosed();
    }
}

inline void Condition::unlock_object(void)
{
    _cond_mutex->unlock();
}

inline void Condition::unlocked_wait(PEGASUS_THREAD_TYPE caller)
{
    unlocked_timed_wait(-1, caller);
}

inline void Condition::unlocked_timed_wait(int milliseconds, PEGASUS_THREAD_TYPE caller)
{
    if(_disallow.get() > 0)
    {
        _cond_mutex->unlock();
        throw ListClosed();
    }

    if(_cond_mutex->_mutex.owner != caller)
        throw Permission((PEGASUS_THREAD_TYPE)caller);
    if(milliseconds == -1)
        milliseconds = INFINITE;

    // Change from PulseEvent to SetEvent, this is part of
    //    fix to avoid deadlock in CIMClient Constructor
    // Change added next line since SignalObjectAndWait
    //       releases the mutex
    _cond_mutex->_mutex.owner = 0;

    DWORD retcode = SignalObjectAndWait(_cond_mutex->_mutex.mut, _condition,
                                            milliseconds, false);
    if(retcode == WAIT_TIMEOUT)
        throw TimeOut(pegasus_thread_self());
    _cond_mutex->lock(caller);
}


#endif // inline native conditional

#endif // IPCWindows_inline_h

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2