<commit_before>#ifndef MEMPOOL_H
#define MEMPOOL_H

#include <cstring>
#include <memory>
#include <vector>

#include "../core/wrappers/atomic.h"

namespace Tempest {

template< class T >
class MemPool {
  public:
    MemPool(){
      aviable.reserve(32);
      data.reserve(32);
      }

    ~MemPool(){
      for( size_t i=0; i<data.size(); ++i )
        delete data[i];
      }

    template< class ... Args >
    T* alloc( Args... a ){
      Detail::Guard guard(spin);
      (void)guard;

      if( aviable.size() ){
        Block *b = aviable.back();
        T* tmp = b->alloc(a...);
        if( b->freedCount==0 )
          aviable.pop_back();
        return tmp;
        }

      data.push_back( new Block() );<commit_msg>fix mempool<commit_after>#ifndef MEMPOOL_H
#define MEMPOOL_H

#include <cstring>
#include <memory>
#include <vector>

#include "../core/wrappers/atomic.h"

namespace Tempest {

template< class T >
class MemPool {
  public:
    MemPool(){
      aviable.reserve(32);
      data.reserve(32);
      }

    ~MemPool(){
      for( size_t i=0; i<data.size(); ++i )
        delete data[i];
      }

    template< class ... Args >
    T* alloc( Args... a ){
      Detail::Guard guard(spin);
      (void)guard;

      if( aviable.size() ){
        Block *b = aviable.back();
        T* tmp = b->alloc(a...);
        if( b->freedCount==0 )
          aviable.pop_back();
        return tmp;
        }

      data.push_back( new Block() );
      aviable.push_back( data.back() );
{'fraction_non_alphanumeric': 0.1639892904953146, 'fraction_numerical': 0.008032128514056224, 'mean_word_length': 2.1210855949895615, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '4577056', 'n_tokens_mistral': 537, 'n_tokens_neox': 524, 'n_words': 117}