// -*-C++-*- 

/*  inc/platform/threads/RecMutex.hpp  */

/*
 * Author: Philogelos A. <Philogelos@yahoo.com>
 * Maintainer: Philogelos A.
 * Keywords: C++, library, containers
 *
 * Copyright (C) 1999 Philogelos A.
 *
 * This file is part of Quercus Robusta.
 *
 * Quercus Robusta is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Library General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This software 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 Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this software; see the file COPYING.LIB.  If not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 */



#ifndef __RECMUTEX_HPP__
#define __RECMUTEX_HPP__

/* $Id$ */

#include "CondVar.hpp"
#include "Object.hpp"
#include "Mutex.hpp"
#include "ThreadsSystem.hpp"
#include "ThreadFactory.hpp"
#include "defines.h"

#define SOLARIS_MGUARD_BUG


#if defined( WANT_SOLARIS_MGUARD_BUG )
#define SOLARIS_MGUARD_BUG
#elif defined( UNWANT_SOLARIS_MGUARD_BUG )
#if defined( SOLARIS_MGUARD_BUG )
#undef SOLARIS_MGUARD_BUG
#endif
#endif

/**

   @author Philogelos
   @created
*/
class RecMutex : public virtual Mutex,
				 public virtual Object
{

  /**
   */
public: RecMutex();
public: RecMutex( CondVar *aCondVar );

public: virtual ~RecMutex();

public: virtual void enter( const Top * = null );
public: virtual void leave( const Top * = null );
public: virtual boolean tryEnter( const Top * = null );

public:  virtual String  toString() const;
public:  virtual String  getClassName() const;

protected: void init( CondVar *aCondVar );

protected: CondVar *condVar;

protected: Index count;
protected: Thread *thread;
protected: Mutex *guardian;
};

/* $Log$ */

/* __RECMUTEX_HPP__ */
#endif
