From 104aeb390591546b27c0144a771dee7b2357332f Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 2 Mar 2015 09:33:57 -0500 Subject: [PATCH 1/2] TDB2 - Commented and reorganized for threading. --- src/Context.cpp | 2 +- src/TDB2.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index 4d0e6bc0b..e7adc9b89 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -275,7 +275,7 @@ int Context::initialize (int argc, const char** argv) //////////////////////////////////////////////////////////////////////////// // - // [8] Run on.launch hooks. + // [8] Initialize hooks. // //////////////////////////////////////////////////////////////////////////// diff --git a/src/TDB2.cpp b/src/TDB2.cpp index d7d17d589..555f32150 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -1179,18 +1179,21 @@ int TDB2::gc () // Allowed as an override, but not recommended. if (context.config.getBoolean ("gc")) { - std::vector pending_tasks = pending.get_tasks (); + std::vector pending_tasks = pending.get_tasks (); + + // TODO Thread. std::vector completed_tasks = completed.get_tasks (); + // TODO Assume pending < completed, therefore there is room here to process + // data before joining with the completed.data thread. + bool pending_changes = false; bool completed_changes = false; - std::vector pending_tasks_after; std::vector completed_tasks_after; // Reduce unnecessary allocation/copies. pending_tasks_after.reserve (pending_tasks.size ()); - completed_tasks_after.reserve (completed_tasks.size ()); // Scan all pending tasks, looking for any that need to be relocated to // completed, or need to be 'woken'. @@ -1227,6 +1230,11 @@ int TDB2::gc () } } + // TODO Join completed.data thread. + + // Reduce unnecessary allocation/copies. + completed_tasks_after.reserve (completed_tasks.size ()); + // Scan all completed tasks, looking for any that need to be relocated to // pending. for (task = completed_tasks.begin (); From a40967a324469ea6b2152ff760eb597887ce32bc Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 2 Mar 2015 11:35:19 -0500 Subject: [PATCH 2/2] Unit Tests - Fixed project.t errors. --- test/project.t | 80 +++++++++----------------------------------------- 1 file changed, 14 insertions(+), 66 deletions(-) diff --git a/test/project.t b/test/project.t index 6d1093ac8..c84e43c5c 100755 --- a/test/project.t +++ b/test/project.t @@ -84,78 +84,26 @@ qx{../src/task rc:$rc add testing project:.myProject. 2>&1 >/dev/null}; $output = qx{../src/task rc:$rc projects 2>&1}; my @lines = split ('\n',$output); -# It's easier to make a pattern for the end than the beginning because priority -# counts are more predictable than project names. -my $project_name_column; -if ($lines[4] =~ s/\d+$//) -{ - $project_name_column = $lines[4]; -} -else -{ - $project_name_column = "error"; -} -like ($project_name_column, qr/^\.myProject\s*$/, "$ut: '.myProject' not indented"); +my ($project_name_column) = $lines[4] =~ /^(\s*\S+)/; +like ($project_name_column, qr/^\.myProject$/, "$ut: '.myProject' not indented"); -if ($lines[5] =~ s/\d+$//) -{ - $project_name_column = $lines[5]; -} -else -{ - $project_name_column = "error"; -} -like ($project_name_column, qr/^\.myProject\.\s*$/, "$ut: '.myProject.' not indented"); +($project_name_column) = $lines[5] =~ /^(\s*\S+)/; +like ($project_name_column, qr/^\.myProject\.$/, "$ut: '.myProject.' not indented"); -if ($lines[6] =~ s/\d+$//) -{ - $project_name_column = "error"; -} -else -{ - $project_name_column = $lines[6]; -} -like ($project_name_column, qr/^abstractParent\s*$/, "$ut: abstract parent not indented and no priority columns"); +($project_name_column) = $lines[6] =~ /^(\s*\S+)/; +like ($project_name_column, qr/^abstractParent$/, "$ut: abstract parent not indented"); -if ($lines[7] =~ s/\d+$//) -{ - $project_name_column = $lines[7]; -} -else -{ - $project_name_column = "error"; -} -like ($project_name_column, qr/^ kid\s*$/, "$ut: child indented and without parent name"); +($project_name_column) = $lines[7] =~ /^(\s*\S+)/; +like ($project_name_column, qr/^ kid$/, "$ut: child indented and without parent name"); -if ($lines[8] =~ s/\d+$//) -{ - $project_name_column = $lines[8]; -} -else -{ - $project_name_column = "error"; -} -like ($project_name_column, qr/^existingParent\s*$/, "$ut: existing parent not indented and has priority columns"); +($project_name_column) = $lines[8] =~ /^(\s*\S+)/; +like ($project_name_column, qr/^existingParent$/, "$ut: existing parent not indented"); -if ($lines[9] =~ s/\d+$//) -{ - $project_name_column = $lines[9]; -} -else -{ - $project_name_column = "error"; -} -like ($project_name_column, qr/^ child\s*$/, "$ut: child of existing parent indented and without parent name"); +($project_name_column) = $lines[9] =~ /^(\s*\S+)/; +like ($project_name_column, qr/^ child$/, "$ut: child of existing parent indented and without parent name"); -if ($lines[12] =~ s/\d+$//) -{ - $project_name_column = $lines[12]; -} -else -{ - $project_name_column = "error"; -} -like ($project_name_column, qr/^myProject\.\s*$/, "$ut: 'myProject.' not indented"); +($project_name_column) = $lines[12] =~ /^(\s*\S+)/; +like ($project_name_column, qr/^myProject\.$/, "$ut: 'myProject.' not indented"); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data), $rc;