aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/scheduler9
-rw-r--r--unit-tests/scheduler/driver.cxx48
2 files changed, 37 insertions, 20 deletions
diff --git a/build2/scheduler b/build2/scheduler
index 99e9524..80b9ec9 100644
--- a/build2/scheduler
+++ b/build2/scheduler
@@ -110,7 +110,7 @@ namespace build2
new (&td->data) task {
&task_count,
decay_copy (forward <F> (f)),
- {decay_copy (forward <A> (a))...}};
+ typename task::args_type (decay_copy (forward <A> (a))...)};
td->thunk = &task_thunk<F, A...>;
}
@@ -235,9 +235,12 @@ namespace build2
template <typename F, typename... A>
struct task_type
{
+ using func_type = std::decay_t<F>;
+ using args_type = std::tuple<std::decay_t<A>...>;
+
atomic_count* task_count;
- std::decay_t<F> func;
- std::tuple<std::decay_t<A>...> args;
+ func_type func;
+ args_type args;
template <size_t... i>
void
diff --git a/unit-tests/scheduler/driver.cxx b/unit-tests/scheduler/driver.cxx
index 65ba5e5..726415a 100644
--- a/unit-tests/scheduler/driver.cxx
+++ b/unit-tests/scheduler/driver.cxx
@@ -17,11 +17,24 @@ using namespace std;
namespace build2
{
+ // Usage argv[0] <max-active-threads>
+ //
int
- main ()
+ main (int argc, char* argv[])
{
- //scheduler s (1);
- scheduler s (scheduler::hardware_concurrency ());
+ bool verb (false);
+ size_t max_active (0);
+
+ if (argc > 1)
+ {
+ verb = true;
+ max_active = stoul (argv[1]);
+ }
+
+ if (max_active == 0)
+ max_active = scheduler::hardware_concurrency ();
+
+ scheduler s (max_active);
auto inner = [] (size_t x, size_t y, size_t& out)
{
@@ -70,25 +83,26 @@ namespace build2
scheduler::stat st (s.shutdown ());
- /*
- cerr << "thread_max_active " << st.thread_max_active << endl
- << "thread_max_total " << st.thread_max_total << endl
- << "thread_helpers " << st.thread_helpers << endl
- << "thread_max_waiting " << st.thread_max_waiting << endl
- << endl
- << "task_queue_depth " << st.task_queue_depth << endl
- << "task_queue_full " << st.task_queue_full << endl
- << endl
- << "wait_queue_slots " << st.wait_queue_slots << endl
- << "wait_queue_collisions " << st.wait_queue_collisions << endl;
- */
+ if (verb)
+ {
+ cerr << "thread_max_active " << st.thread_max_active << endl
+ << "thread_max_total " << st.thread_max_total << endl
+ << "thread_helpers " << st.thread_helpers << endl
+ << "thread_max_waiting " << st.thread_max_waiting << endl
+ << endl
+ << "task_queue_depth " << st.task_queue_depth << endl
+ << "task_queue_full " << st.task_queue_full << endl
+ << endl
+ << "wait_queue_slots " << st.wait_queue_slots << endl
+ << "wait_queue_collisions " << st.wait_queue_collisions << endl;
+ }
return 0;
}
}
int
-main ()
+main (int argc, char* argv[])
{
- return build2::main ();
+ return build2::main (argc, argv);
}