Skip to content

Commit

Permalink
Parallelized task execution, fixed bug when removing multiple tasks. C…
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdenCullen committed Apr 24, 2014
1 parent b1feec6 commit 0d6cc40
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/utility/tasks.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
*
*/
module utility.tasks;
import utility.time;
import utility.time, utility.output;

import gl3n.util: is_vector, is_matrix, is_quaternion;
import gl3n.interpolate: lerp;

import core.time;
import std.algorithm: min;
import std.parallelism: parallel;

public:
/**
Expand Down Expand Up @@ -258,12 +259,12 @@ void scheduleDelayedTask( void delegate() dg, Duration delay )
void executeTasks()
{
size_t[] toRemove; // Indicies of tasks which are done
foreach( i, task; scheduledTasks )
foreach( i, task; parallel( scheduledTasks ) )
{
if( task() )
toRemove ~= i;
synchronized toRemove ~= i;
}
foreach( i; toRemove )
foreach_reverse( i; toRemove )
{
// Get tasks after one being removed
auto end = scheduledTasks[ i+1..$ ];
Expand Down

0 comments on commit 0d6cc40

Please sign in to comment.