<commit_before>#ifndef BABYLON_CORE_FUTURE_H
#define BABYLON_CORE_FUTURE_H

#include <babylon/babylon_global.h>
#include <babylon/core/active.h>
#include <babylon/core/move_on_copy.h>

namespace BABYLON {

/**
 * Generic helper function to avoid repeating the steps for managing
 * asynchronous task job (by active object) that returns a future results
 * could of course be made even more generic if done more in the way of
 * std::async, ref: http://en.cppreference.com/w/cpp/thread/async
 */
template <typename Func, class BgWorker>
::std::future<typename ::std::result_of<Func()>::type>
spawn_task(Func func, BgWorker* worker)
{
  typedef typename ::std::result_of<Func()>::type result_type;
  typedef ::std::packaged_task<result_type()> task_type;

  if (nullptr == worker) {
    auto p = ::std::make_shared<::std::promise<result_type>>();
    ::std::future<result_type> future_result = p->get_future();
    p->set_exception(::std::make_exception_ptr(
      ::std::runtime_error("nullptr instantiated worker")));
    return future_result;
  }

  task_type task(::std::move(func));

  ::std::future<result_type> result = task.get_future();
  worker->send(MoveOnCopy<task_type>(::std::move(task)));
  return ::std::move(result);
}

} // end of namespace BABYLON

#endif // end of BABYLON_CORE_DELEGATE_H<commit_msg>Fixed wrong comment<commit_after>#ifndef BABYLON_CORE_FUTURE_H
#define BABYLON_CORE_FUTURE_H

#include <babylon/babylon_global.h>
#include <babylon/core/active.h>
#include <babylon/core/move_on_copy.h>

namespace BABYLON {

/**
 * Generic helper function to avoid repeating the steps for managing
 * asynchronous task job (by active object) that returns a future results
 * could of course be made even more generic if done more in the way of
 * std::async, ref: http://en.cppreference.com/w/cpp/thread/async
 */
template <typename Func, class BgWorker>
::std::future<typename ::std::result_of<Func()>::type>
spawn_task(Func func, BgWorker* worker)
{
  typedef typename ::std::result_of<Func()>::type result_type;
  typedef ::std::packaged_task<result_type()> task_type;

  if (nullptr == worker) {
    auto p = ::std::make_shared<::std::promise<result_type>>();
    ::std::future<result_type> future_result = p->get_future();
    p->set_exception(::std::make_exception_ptr(
      ::std::runtime_error("nullptr instantiated worker")));
    return future_result;
  }

  task_type task(::std::move(func));

  ::std::future<result_type> result = task.get_future();
  worker->send(MoveOnCopy<task_type>(::std::move(task)));
  return ::std::move(result);
}

} // end of namespace BABYLON

#endif // end of BABYLON_CORE_FUTURE_H
{'fraction_non_alphanumeric': 0.14696969696969697, 'fraction_numerical': 0.0, 'mean_word_length': 5.754475703324808, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 35, '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': '5516785', 'n_tokens_mistral': 918, 'n_tokens_neox': 889, 'n_words': 201}