<commit_before>/****************** <VPR heading BEGIN do not edit this line> *****************
 *
 * VR Juggler Portable Runtime
 *
 * Original Authors:
 *   <NAME>, <NAME>, <NAME>, <NAME>
 *
 ****************** <VPR heading END do not edit this line> ******************/

/*************** <auto-copyright.pl BEGIN do not edit this line> **************
 *
 * VR Juggler is (C) Copyright 1998-2006 by Iowa State University
 *
 * Original Authors:
 *   <NAME>, <NAME>,
 *   <NAME>, <NAME>,
 *   <NAME>, <NAME>
 *
 * This library 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 of the License, or (at your option) any later version.
 *
 * This library 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 library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 *************** <auto-copyright.pl END do not edit this line> ***************/

#ifndef _VPR_RWGuard_h_
#define _VPR_RWGuard_h_

#include <vpr/vprConfig.h>
#include <vpr/Util/ReturnStatus.h>
#include <vpr/Sync/RWMutex.h>


namespace vpr
{

/** \class ReadGuard RWGuard.h vpr/Sync/RWGuard.h
 *
 * Read Guard wrapper.
 */
class ReadGuard
{
public:
   /**
    * Acquires the lock implicitly.
    * If \p block is 1, then use a blocking acquire.
    */
   ReadGuard(RWMutex& lock, int block = 1) : mTheLock(&lock)
   {
      mLockStatus = block ? acquire().success() : tryAcquire().success();
   }

   /** Releases the lock. */
   ~ReadGuard()
   {
      if ( mLockStatus )
      {
         mTheLock->release();
      }
   }

   /**
    * @return \c true is returned if this guard is locked.
    * @return \c false is returned if this guard is not locked.
    */
   const bool& locked()
   {
      return mLockStatus;
   }

   /** Acquires the lock. */
   vpr::ReturnStatus acquire()
   {
      return mTheLock->acquireRead();
   }

   /** Tries to acquire the lock. */
   vpr::ReturnStatus tryAcquire()
   {
      return mTheLock->tryAcquireRead();
   }

   /** Explicity releases the lock. */
   vpr::ReturnStatus release()
   {
      mLockStatus = false;
      return mTheLock->release();
   }

private:
   RWMutex* mTheLock;    /**< The lock that we are using */
   bool     mLockStatus; /**< Are we locked or not */
};

/** \class WriteGuard RWGuard.h vpr/Sync/RWGuard.h
 *
 * Write Guard wrapper.
 */
class WriteGuard
{
public:
   /**
    * Acquires the lock implicitly.
    * If \p block is 1, then use a blocking acquire.
    */
   WriteGuard(RWMutex& lock, int block = 1) : mTheLock(&lock)
   {
      mLockStatus = block ? acquire().success() : tryAcquire().success();
   }

   /** Releases the lock. */
   ~WriteGuard()
   {
      if ( mLockStatus )
      {
         mTheLock->release();
      }
   }

   /**
    * @return \c true is returned if this guard is locked.
    * @return \c false is returned if this guard is not locked.
    */
   const bool& locked()
   {
      return mLockStatus;
   }

   /** Acquires the lock. */
   vpr::ReturnStatus acquire()
   {
      return mTheLock->acquireWrite();
   }

   /** Tries to acquire lock. */
   vpr::ReturnStatus tryAcquire()
   {
      return mTheLock->tryAcquireWrite();
   }

   /** Explicity releases the lock. */
   vpr::ReturnStatus release()
   {
      mLockStatus = false;
      return mTheLock->release();
   }

private:
   RWMutex* mTheLock;    /**< The lock that we are using */
   bool     mLockStatus; /**< Are we locked or not */
};

} // End of vpr namespace


#endif
<commit_msg>Updated for the removal of vpr::ReturnStatus from vpr::RWMutex.<commit_after>/****************** <VPR heading BEGIN do not edit this line> *****************
 *
 * VR Juggler Portable Runtime
 *
 * Original Authors:
 *   <NAME>, <NAME>, <NAME>, <NAME>
 *
 ****************** <VPR heading END do not edit this line> ******************/

/*************** <auto-copyright.pl BEGIN do not edit this line> **************
 *
 * VR Juggler is (C) Copyright 1998-2006 by Iowa State University
 *
 * Original Authors:
 *   <NAME>, <NAME>,
 *   <NAME>, <NAME>,
 *   <NAME>, <NAME>
 *
 * This library 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 of the License, or (at your option) any later version.
 *
 * This library 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 library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 *************** <auto-copyright.pl END do not edit this line> ***************/

#ifndef _VPR_RWGuard_h_
#define _VPR_RWGuard_h_

#include <vpr/vprConfig.h>
#include <vpr/Util/ReturnStatus.h>
#include <vpr/Sync/RWMutex.h>


namespace vpr
{

/** \class ReadGuard RWGuard.h vpr/Sync/RWGuard.h
 *
 * Read Guard wrapper.
 */
class ReadGuard
{
public:
   /**
    * Acquires the read lock implicitly. If \p block is true, then use a
    * blocking read lock acquisition operation. Otherwise, use a non-blocking
    * read lock acquisition call.
    *
    * @post \c mLockStatus reflects whether the given read lock was acquired.
    *
    * @param lock  The read-write mutex to associate with this guard.
    * @param block A flag indicating whether a blocking read lock acquisition
    *              operation should be used to acquire the lock. This
    *              parameter is optional and defaults to true if it is not
    *              specified.
    */
   ReadGuard(RWMutex& lock, bool block = true)
      : mTheLock(&lock)
   {
      mLockStatus = block ? acquire() : tryAcquire();
   }

   /** Releases the lock. */
   ~ReadGuard()
   {
      if ( mLockStatus )
      {
         mTheLock->release();
      }
   }

   /**
    * Indicates whether this read guard is currently locked.
    *
    * @return \c true is returned if this guard is locked; \c false is
    *         returned otherwise.
    */
   bool locked() const
   {
      return mLockStatus;
   }

   /** Acquires a read lock. */
   bool acquire()
   {
      mTheLock->acquireRead();
      mLockStatus = true;
      return mLockStatus;
   }

   /** Tries to acquire a read lock. */
   bool tryAcquire()
   {
      mLockStatus = mTheLock->tryAcquireRead();
      return mLockStatus;
   }

   /** Explicity releases the read lock. */
   void release()
   {
      mLockStatus = false;
      mTheLock->release();
   }

private:
   RWMutex* mTheLock;    /**< The lock that we are using */
   bool     mLockStatus; /**< Are we locked or not */
};

/** \class WriteGuard RWGuard.h vpr/Sync/RWGuard.h
 *
 * Write Guard wrapper.
 */
class WriteGuard
{
public:
   /**
    * Acquires the write lock implicitly. If \p block is true, then use a
    * blocking write lock acquisition operation. Otherwise, use a non-blocking
    * write lock acquisition call.
    *
    * @post \c mLockStatus reflects whether the given write lock was acquired.
    *
    * @param lock  The read-write mutex to associate with this guard.
    * @param block A flag indicating whether a blocking write lock acquisition
    *              operation should be used to acquire the lock. This
    *              parameter is optional and defaults to true if it is not
    *              specified.
    */
   WriteGuard(RWMutex& lock, bool block = true)
      : mTheLock(&lock)
   {
      mLockStatus = block ? acquire() : tryAcquire();
   }

   /** Releases the write lock. */
   ~WriteGuard()
   {
      if ( mLockStatus )
      {
         mTheLock->release();
      }
   }

   /**
    * Indicates whether this read guard is currently locked.
    *
    * @return \c true is returned if this guard is locked; \c false is
    *         returned otherwise.
    */
   bool locked() const
   {
      return mLockStatus;
   }

   /** Acquires the write lock. */
   bool acquire()
   {
      mTheLock->acquireWrite();
      mLockStatus = true;
      return mLockStatus;
   }

   /** Tries to acquire write lock. */
   bool tryAcquire()
   {
      mLockStatus = mTheLock->tryAcquireWrite();
      return mLockStatus;
   }

   /** Explicity releases the write lock. */
   void release()
   {
      mLockStatus = false;
      mTheLock->release();
   }

private:
   RWMutex* mTheLock;    /**< The lock that we are using */
   bool     mLockStatus; /**< Are we locked or not */
};

} // End of vpr namespace


#endif

{'fraction_non_alphanumeric': 0.13161959399823478, 'fraction_numerical': 0.005516328331862313, 'mean_word_length': 2.541015625, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2114522', 'n_tokens_mistral': 2757, 'n_tokens_neox': 2694, 'n_words': 974}