<commit_before>////////////////////////////////////////////////////////////////////////////////
/// @brief base transaction wrapper
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author <NAME>
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

#ifndef TRIAGENS_UTILS_TRANSACTION_H
#define TRIAGENS_UTILS_TRANSACTION_H 1

#include "Basics/Common.h"

#include "Cluster/ServerState.h"

#include "VocBase/barrier.h"
#include "VocBase/collection.h"
#include "VocBase/document-collection.h"
#include "VocBase/edge-collection.h"
#include "VocBase/transaction.h"
#include "VocBase/update-policy.h"
#include "VocBase/vocbase.h"
#include "VocBase/voc-shaper.h"
#include "VocBase/voc-types.h"

#include "BasicsC/logging.h"
#include "BasicsC/random.h"
#include "BasicsC/tri-strings.h"

#include "Utils/CollectionNameResolver.h"
#include "Utils/DocumentHelper.h"

namespace triagens {
  namespace arango {

// -----------------------------------------------------------------------------
// --SECTION--                                             class TransactionBase
// -----------------------------------------------------------------------------

    class TransactionBase {

////////////////////////////////////////////////////////////////////////////////
/// @brief Transaction base, every transaction class has to inherit from here
////////////////////////////////////////////////////////////////////////////////

      public:
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////

        TransactionBase () {
          TRI_ASSERT(_numberTrxInScope >= 0);
            TRI_ASSERT(_numberTrxInScope == _numberTrxActive);
            _numberTrxInScope++;
          }

////////////////////////////////////////////////////////////////////////////////
/// @brief destructor
////////////////////////////////////////////////////////////////////////////////

          virtual ~TransactionBase () {
            TRI_ASSERT(_numberTrxInScope > 0);
            _numberTrxInScope--;
            // Note that embedded transactions might have seen a begin()
            // but no abort() or commit(), so _numberTrxActive might
            // be one too big. We simply fix it here:
            _numberTrxActive = _numberTrxInScope;
          }

////////////////////////////////////////////////////////////////////////////////
/// @brief assert that a transaction object is in scope in the current thread
////////////////////////////////////////////////////////////////////////////////

          static void assertSomeTrxInScope () {
            TRI_ASSERT(_numberTrxInScope > 0);
          }

////////////////////////////////////////////////////////////////////////////////
/// @brief assert that the innermost transaction object in scope in the 
/// current thread is actually active (between begin() and commit()/abort().
////////////////////////////////////////////////////////////////////////////////

          static void assertCurrentTrxActive () {
            TRI_ASSERT(_numberTrxInScope > 0 &&
                       _numberTrxInScope == _numberTrxActive);
          }

////////////////////////////////////////////////////////////////////////////////
/// @brief the following is for the runtime protection check, number of
/// transaction objects in scope in the current thread
////////////////////////////////////////////////////////////////////////////////

        protected:

          static thread_local int _numberTrxInScope;

////////////////////////////////////////////////////////////////////////////////
/// @brief the following is for the runtime protection check, number of
/// transaction objects in the current thread that are active (between
/// begin and commit()/abort().
////////////////////////////////////////////////////////////////////////////////

          static thread_local int _numberTrxActive;

      };

// -----------------------------------------------------------------------------
// --SECTION--                                                 class Transaction
// -----------------------------------------------------------------------------

      template<typename T>
      class Transaction : public T, public TransactionBase {

////////////////////////////////////////////////////////////////////////////////
/// @brief Transaction
////////////////////////////////////////////////////////////////////////////////

        private:
          Transaction (const Transaction&) = delete;
          Transaction& operator= (const Transaction&) = delete;

// -----------------------------------------------------------------------------
// --SECTION--                                      constructors and destructors
// -----------------------------------------------------------------------------

        public:

////////////////////////////////////////////////////////////////////////////////<commit_msg>Fake TransactionBase.<commit_after>////////////////////////////////////////////////////////////////////////////////
/// @brief base transaction wrapper
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author <NAME>
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

#ifndef TRIAGENS_UTILS_TRANSACTION_H
#define TRIAGENS_UTILS_TRANSACTION_H 1

#include "Basics/Common.h"

#include "Cluster/ServerState.h"

#include "VocBase/barrier.h"
#include "VocBase/collection.h"
#include "VocBase/document-collection.h"
#include "VocBase/edge-collection.h"
#include "VocBase/transaction.h"
#include "VocBase/update-policy.h"
#include "VocBase/vocbase.h"
#include "VocBase/voc-shaper.h"
#include "VocBase/voc-types.h"

#include "BasicsC/logging.h"
#include "BasicsC/random.h"
#include "BasicsC/tri-strings.h"

#include "Utils/CollectionNameResolver.h"
#include "Utils/DocumentHelper.h"

namespace triagens {
  namespace arango {

// -----------------------------------------------------------------------------
// --SECTION--                                             class TransactionBase
// -----------------------------------------------------------------------------

    class TransactionBase {

////////////////////////////////////////////////////////////////////////////////
/// @brief Transaction base, every transaction class has to inherit from here
////////////////////////////////////////////////////////////////////////////////

      public:
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////

        TransactionBase () {
          TRI_ASSERT(_numberTrxInScope >= 0);
          TRI_ASSERT(_numberTrxInScope == _numberTrxActive);
          _numberTrxInScope++;
        }

        TransactionBase (bool standalone) {
          TRI_ASSERT(_numberTrxInScope >= 0);
          TRI_ASSERT(_numberTrxInScope == _numberTrxActive);
          _numberTrxInScope++;
          if (standalone) {
            _numberTrxActive++;
          }
        }

////////////////////////////////////////////////////////////////////////////////
/// @brief destructor
////////////////////////////////////////////////////////////////////////////////

        virtual ~TransactionBase () {
          TRI_ASSERT(_numberTrxInScope > 0);
          _numberTrxInScope--;
          // Note that embedded transactions might have seen a begin()
          // but no abort() or commit(), so _numberTrxActive might
          // be one too big. We simply fix it here:
          _numberTrxActive = _numberTrxInScope;
        }

////////////////////////////////////////////////////////////////////////////////
/// @brief assert that a transaction object is in scope in the current thread
////////////////////////////////////////////////////////////////////////////////

        static void assertSomeTrxInScope () {
          TRI_ASSERT(_numberTrxInScope > 0);
        }

////////////////////////////////////////////////////////////////////////////////
/// @brief assert that the innermost transaction object in scope in the 
/// current thread is actually active (between begin() and commit()/abort().
////////////////////////////////////////////////////////////////////////////////

        static void assertCurrentTrxActive () {
          TRI_ASSERT(_numberTrxInScope > 0 &&
                     _numberTrxInScope == _numberTrxActive);
        }

////////////////////////////////////////////////////////////////////////////////
/// @brief the following is for the runtime protection check, number of
/// transaction objects in scope in the current thread
////////////////////////////////////////////////////////////////////////////////

      protected:

        static thread_local int _numberTrxInScope;

////////////////////////////////////////////////////////////////////////////////
/// @brief the following is for the runtime protection check, number of
/// transaction objects in the current thread that are active (between
/// begin and commit()/abort().
////////////////////////////////////////////////////////////////////////////////

        static thread_local int _numberTrxActive;

      };

// -----------------------------------------------------------------------------
// --SECTION--                                                 class Transaction
// -----------------------------------------------------------------------------

      template<typename T>
      class Transaction : public T, public TransactionBase {

////////////////////////////////////////////////////////////////////////////////
/// @brief Transaction
////////////////////////////////////////////////////////////////////////////////

        private:
          Transaction (const Transaction&) = delete;
          Transaction& operator= (const Transaction&) = delete;

// -----------------------------------------------------------------------------
// --SECTION--                                      constructors and destructors
// -----------------------------------------------------------------------------

        public:

////////////////////////////////////////////////////////////////////////////////
{'fraction_non_alphanumeric': 0.40670591246480675, 'fraction_numerical': 0.0043511645764013306, 'mean_word_length': 0.8692393557646308, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2331388', 'n_tokens_mistral': 2240, 'n_tokens_neox': 2146, 'n_words': 678}