Archived
1
0

Revert "Multi-thread grades generation"

This reverts commit 2e5b2af4d8.
This commit is contained in:
Charlie Noyce Root 2014-01-17 02:17:41 +01:00
parent 2e5b2af4d8
commit b8d4ff1a58

View File

@ -2,7 +2,6 @@
use v5.10.1; use v5.10.1;
use strict; use strict;
use threads;
use warnings; use warnings;
use Carp; use Carp;
use Pod::Usage; use Pod::Usage;
@ -99,38 +98,7 @@ sub grades_generate
my @trace_dirs = grep { ( ! /^\./ ) && -d "$basedir/$year/$project_id/traces/$_" } readdir($dh); my @trace_dirs = grep { ( ! /^\./ ) && -d "$basedir/$year/$project_id/traces/$_" } readdir($dh);
closedir $dh; closedir $dh;
my @ths; for my $login (@logins)
my $max_ths = 4;
my $login_by_threads = @logins / $max_ths;
for (my $i = 0; $i < $max_ths; $i++)
{
my @partlogin = @logins[($i*$login_by_threads) .. (($i+1)*$login_by_threads - 1)];
push @ths, threads->create(\&do_grade_generation, $grading, $year, $project_id, $groups, \@trace_dirs, @partlogin);
}
if ($login_by_threads * $max_ths < @logins)
{
my @partlogin = @logins[$login_by_threads * $max_ths .. $#logins];
push @ths, threads->create(\&do_grade_generation, $grading, $year, $project_id, $groups, \@trace_dirs, @partlogin);
}
for my $th (@ths) {
$th->join();
}
return 1;
}
sub do_grade_generation
{
my $grading = shift;
my $year = shift;
my $project_id = shift;
my $groups = shift;
my @trace_dirs = @{ shift() };
for my $login (@_)
{ {
my @files; my @files;
@ -189,6 +157,8 @@ sub do_grade_generation
$grading->reset(); $grading->reset();
} }
return 1;
} }
sub grades_new_bonus sub grades_new_bonus