<commit_before>/***************************************************************************
                          criticalsection.h  -  CriticalSection
                             -------------------
    begin                : lun avr 21 2003
    copyright            : (C) 2003 by <NAME>
    email                : <EMAIL>
 ***************************************************************************/

/***************************************************************************
 * Copyright (C) The Apache Software Foundation. All rights reserved.      *
 *                                                                         *
 * This software is published under the terms of the Apache Software       *
 * License version 1.1, a copy of which has been included with this        *
 * distribution in the LICENSE.txt file.                                   *
 ***************************************************************************/

#ifndef _LOG4CXX_HELPERS_CRITICAL_SECTION_H
#define _LOG4CXX_HELPERS_CRITICAL_SECTION_H

#include <log4cxx/config.h>

namespace log4cxx
{
	namespace helpers
	{
		class CriticalSection
		{
		public:
			CriticalSection();
			~CriticalSection();
			void lock();
			void unlock();

		protected:
			void * mutex;
		};
	}; // namespace helpers
}; // namespace log4cxx

#endif //_LOG4CXX_HELPERS_CRITICAL_SECTION_H<commit_msg>added helper class<commit_after>/***************************************************************************
                          criticalsection.h  -  CriticalSection
                             -------------------
    begin                : lun avr 21 2003
    copyright            : (C) 2003 by <NAME>
    email                : <EMAIL>
 ***************************************************************************/

/***************************************************************************
 * Copyright (C) The Apache Software Foundation. All rights reserved.      *
 *                                                                         *
 * This software is published under the terms of the Apache Software       *
 * License version 1.1, a copy of which has been included with this        *
 * distribution in the LICENSE.txt file.                                   *
 ***************************************************************************/

#ifndef _LOG4CXX_HELPERS_CRITICAL_SECTION_H
#define _LOG4CXX_HELPERS_CRITICAL_SECTION_H

#include <log4cxx/config.h>

namespace log4cxx
{
	namespace helpers
	{
		class CriticalSection
		{
		public:
			CriticalSection();
			~CriticalSection();
			void lock();
			void unlock();

			void * mutex;
		};

		/** CriticalSection helper class to be used on call stack
		*/
		class WaitAccess
		{
		public:
			/// lock a critical section
			WaitAccess(CriticalSection& cs) : cs(cs)
			{
				cs.lock();
				locked = true;
			}

			/** automatically unlock the critical section
			if unlock has not be called.
			*/
			~WaitAccess()
			{
				if (locked)
				{
					unlock();
				}
			}

			/// unlock the critical section
			void unlock()
			{
				cs.unlock();
				locked = false;
			}

		private:
			/// the CriticalSection to be automatically unlocked
			CriticalSection& cs;
			/// verify the CriticalSection state
			bool locked;
		};
	}; // namespace helpers
}; // namespace log4cxx

#endif //_LOG4CXX_HELPERS_CRITICAL_SECTION_H
{'fraction_non_alphanumeric': 0.25498957402442657, 'fraction_numerical': 0.010723860589812333, 'mean_word_length': 2.2164750957854404, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3820176', 'n_tokens_mistral': 969, 'n_tokens_neox': 773, 'n_words': 221}