#ifndef SORT_TASK_HPP
#define SORT_TASK_HPP

#include <iostream>
#include <algorithm>
#include <unistd.h>
#include <cstdlib>
#include <ctime>

#include "Task.hpp"

class SortTask : public Task{
	private:
		int* matrix;
		int n;
	public:
		SortTask(int* mat , int size) : matrix(mat) , n(size) {}

		void execute_task(int worker_id, int worker_count){
			srand(time(0)^getpid());

			for(int i=0;i<n;i++){
				if(i%worker_count == worker_id%worker_count){
					std::cout<<"PID " << getpid() << " PPID " << getppid() << " [Worker " << worker_id << "] \n";

					int* row_start = matrix+(i*n);
					std::sort(row_start, n+row_start);
				}
			}
		}
};
#endif

