<commit_before>/**
 *  @file
 *  @copyright defined in eos/LICENSE.txt
 */

#include <eosio/chain/exceptions.hpp>
#include <eosio/chain/types.hpp>

#include <fc/thread_pool.hpp>
#include <fc/exception/exception.hpp>

#include <boost/test/unit_test.hpp>


BOOST_AUTO_TEST_SUITE(thread_pool_tests)

BOOST_AUTO_TEST_CASE(basic)
{ try {

      fc::thread_pool pool;
      pool.init( 5 );

      auto f1 = pool.async( []() {
         fc::flat_set<eosio::chain::public_key_type> tmp;
         tmp.emplace();
         return tmp;
      } );

      auto set1 = f1.get();

      BOOST_CHECK_EQUAL( 1, set1.size());

      pool.stop();

} FC_LOG_AND_RETHROW() }
<commit_msg>test boost::asio::thread_pool<commit_after>/**
 *  @file
 *  @copyright defined in eos/LICENSE.txt
 */

#include <eosio/chain/exceptions.hpp>
#include <eosio/chain/types.hpp>

#include <fc/thread_pool.hpp>
#include <fc/exception/exception.hpp>

#include <boost/test/unit_test.hpp>
#include <boost/asio/thread_pool.hpp>
#include <boost/asio.hpp>


BOOST_AUTO_TEST_SUITE(thread_pool_tests)

template<typename F>
auto async( boost::asio::thread_pool& pool, F&& f ) {
   auto task = std::make_shared<std::packaged_task<decltype( f() )()>>( std::forward<F>(f) );
   boost::asio::post( pool, [task]() { (*task)(); } );
   return task->get_future();
}


BOOST_AUTO_TEST_CASE(basic)
{ try {

      fc::thread_pool pool;
      pool.init( 5 );

      auto f1 = pool.async( []() {
         fc::flat_set<eosio::chain::public_key_type> tmp;
         tmp.emplace();
         return tmp;
      } );

      auto set1 = f1.get();

      BOOST_CHECK_EQUAL( 1, set1.size());

      pool.stop();

      boost::asio::thread_pool p(5);

      auto f2 = async( p, []() {
         fc::flat_set<eosio::chain::public_key_type> tmp;
         tmp.emplace();
         return tmp;
      });

      auto set2 = f2.get();

      BOOST_CHECK_EQUAL( 1, set2.size());

      p.join();
      p.stop();

} FC_LOG_AND_RETHROW() }

{'fraction_non_alphanumeric': 0.16973415132924335, 'fraction_numerical': 0.009202453987730062, 'mean_word_length': 3.0770833333333334, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 23, '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': '2113470', 'n_tokens_mistral': 762, 'n_tokens_neox': 727, 'n_words': 121}