
#ifndef PLS_PARALLEL_ITERATOR_TASK_H
#define PLS_PARALLEL_ITERATOR_TASK_H

#include "abstract_task.h"

namespace pls {
namespace internal {
namespace scheduling {
template<typename RandomIt, typename Function>
class parallel_iterator_task : public abstract_task {
  RandomIt first_, last_;
  Function function_;

  // External stealing
  size_t first_index_ava, last_index_ava;
  // My internal state
  size_t current_index, max_index;

 protected:
  bool internal_stealing(abstract_task *other_task) override;
  bool split_task(base::swmr_spin_lock * /*lock*/) override;

 public:
  explicit parallel_iterator_task(RandomIt first, RandomIt last, Function function, const abstract_task::id &id);
  void execute() override;
};
}
}
}
#include "parallel_iterator_task_impl.h"

#endif //PLS_PARALLEL_ITERATOR_TASK_H
