Newer
Older
// static Vector3D fakeSource(config.R, 0, 0);
// randomly pick up two pixels
Vector3D site1 = config->pixels[i];
Vector3D site2 = config->pixels[j];
site1.Z = (2 * float(std::rand()) / RAND_MAX - 1) * config->pitchZ / 2.0;
site2.Z = (2 * float(std::rand()) / RAND_MAX - 1) * config->pitchZ / 2.0;
double cosAngle = getCosAngle(site1 - config->trueSource, axis);
}
void * Worker::handle(void *ptr) {
while(1) {
//some work to get data (read board or file)
for (int i = 0; i < config->chuckSize; i++)
{
coneQueue->enqueue(createCone(config));
}
counts += config->chuckSize;
while (coneQueue->size_approx() >= config->capacity)
{
gSystem->Sleep(50);
}
// printf("You are in worker Thread. Total counts is: %lld\n", counts);
}
}
void * Worker::reader(void *ptr) {
std::ifstream conefile;
std::string fpath("/media/ming/DATA/projects/Imager/polimi/cones.txt");
conefile.open(fpath, std::ios::in);
std::string line;
// skip header (first line)
std::getline(conefile, line);
while(1) {
//some work to get data (read board or file)
int i(0);
while (i < config->chuckSize && std::getline(conefile, line))
{
coneQueue->enqueue(Cone(line));
i++;
}
counts += i;
if (conefile.eof())
{
// TODO
// emit processing finished signal to maain thread
}
while (coneQueue->size_approx() >= config->capacity)
{
gSystem->Sleep(50);
}
// printf("You are in worker Thread. Total counts is: %lld\n", counts);
}
conefile.close();