<commit_before>// Each task is represented by a front-end given back to the user, which can be
// used to access the result of the computation. This file defines this front
// end.
//
// The only thing the user has access is to the type of result provided by the
// computing unit used to create the task, as it identifies which time it can be
// converted.
//
// The usual method to access the result is just to cast the task, like:
// Task<int> t = ...;
// int bar = ...;
// int foo = t + bar;
//
// This automatically coerces the task to its type. If the result hasn't been
// computed yet (maybe because the task manager hasn't run), it is computed
// locally at the time of coercion.
//
// The operator() is provided and behaves like coercing, but some functions,
// like printf, will give error because they don't explicit allows type
// conversion.

#ifndef __TASK_DISTRIBUTION__TASK_HPP__
#define __TASK_DISTRIBUTION__TASK_HPP__

#include "key.hpp"

namespace TaskDistribution {
  class TaskManager;

  template <class T>
  class Task {
    public:
      Task(): task_manager_(nullptr) { }

      Task(Task<T> const& other) {
        task_key_ = other.task_key_;
        task_manager_ = other.task_manager_;
      }

      Task<T> const& operator=(Task<T> const& other) {
        task_key_ = other.task_key_;
        task_manager_ = other.task_manager_;
        return *this;
      }

      // Can't use operator== as it may force type coercion
      bool is_same_task(Task<T> const& other) const {
        return task_key_ == other.task_key_ &&
               task_manager_ == other.task_manager_;
      }

      template <class Other>
      bool is_same_task(Task<Other> const& other) const {
        return false;
      }

      operator T() const;

      T operator()() const {
        return (T)*this;
      }

    private:
      friend class TaskManager;

      Task(Key task_key, TaskManager* task_manager):
        task_key_(task_key),
        task_manager_(task_manager) { }

      Key task_key_;

      TaskManager* task_manager_;
  };
};

#include "task_impl.hpp"

#endif
<commit_msg>Added documentation to task.hpp.<commit_after>// Each task is represented by a front-end given back to the user, which can be
// used to access the result of the computation. This file defines this front
// end.
//
// The only thing the user has access is to the type of result provided by the
// computing unit used to create the task, as it identifies which time it can be
// converted.
//
// The usual method to access the result is just to cast the task, like:
// Task<int> t = ...;
// int bar = ...;
// int foo = t + bar;
//
// This automatically coerces the task to its type. If the result hasn't been
// computed yet (maybe because the task manager hasn't run), it is computed
// locally at the time of coercion.
//
// The operator() is provided and behaves like coercing, but some functions,
// like printf, will give error because they don't implicitly perform type
// conversion.

#ifndef __TASK_DISTRIBUTION__TASK_HPP__
#define __TASK_DISTRIBUTION__TASK_HPP__

#include "key.hpp"

namespace TaskDistribution {
  class TaskManager;

  template <class T>
  class Task {
    public:
      Task(): task_manager_(nullptr) { }

      Task(Task<T> const& other) {
        task_key_ = other.task_key_;
        task_manager_ = other.task_manager_;
      }

      Task<T> const& operator=(Task<T> const& other) {
        task_key_ = other.task_key_;
        task_manager_ = other.task_manager_;
        return *this;
      }

      // Can't use operator== as it may force type coercion
      bool is_same_task(Task<T> const& other) const {
        return task_key_ == other.task_key_ &&
               task_manager_ == other.task_manager_;
      }

      template <class Other>
      bool is_same_task(Task<Other> const& other) const {
        return false;
      }

      operator T() const;

      T operator()() const {
        return (T)*this;
      }

    private:
      friend class TaskManager;

      Task(Key task_key, TaskManager* task_manager):
        task_key_(task_key),
        task_manager_(task_manager) { }

      Key task_key_;

      TaskManager* task_manager_;
  };
};

#include "task_impl.hpp"

#endif

{'fraction_non_alphanumeric': 0.09555345316934721, 'fraction_numerical': 0.0, 'mean_word_length': 2.6456896551724136, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '1018843', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1227, 'n_words': 459}