Skip to content
Snippets Groups Projects
PthreadSimulation.cpp 765 B
Newer Older
#include "PthreadSimulation.hpp"

namespace nbody {
	PthreadSimulation::PthreadSimulation() {
		this->correctState = -1;
	}

	PthreadSimulation::~PthreadSimulation() {
	}

	void PthreadSimulation::cleanup() {

	}

	int PthreadSimulation::getNumberOfProcesses() {
		return this->threads.size();
	}

	int PthreadSimulation::getProcessId() {
		vector<pthread_t>::iterator it = this->threads.begin();
		int id = 0;

		while (*it != pthread_self() && it != this->threads.end()) {
			id++;
			it++;
		}
		if (it != this->threads.end()) {
			return id;
		} else {
			return -1;
		}
	}

	bool PthreadSimulation::readInputData(string filename) {
		this->bodies = Tree::dubinskiParse(filename);
		return !this->bodies.empty();
	}

	void PthreadSimulation::runStep() {

	}

}