Skip to content

Commit

Permalink
Review code
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Sep 10, 2023
1 parent c511fc2 commit 4038801
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace barrier_example {
public:
static void main() {
for (auto index = 0; index < task_count; ++index)
thread_pool::queue_user_work_item(wait_callback {perform_phase});
thread_pool::queue_user_work_item(perform_phase);

thread::join_all();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace monitor_lock_example {
// Set the number of synchronized calls.
num_ops = 5;
for (int ctr = 0; ctr <= 4; ++ctr)
thread_pool::queue_user_work_item(wait_callback {sync_update_resource});
thread_pool::queue_user_work_item(sync_update_resource);

// Wait until this WaitHandle is signaled.
ops_are_done.wait_one();
Expand All @@ -63,7 +63,7 @@ namespace monitor_lock_example {
// Reset the count for unsynchronized calls.
num_ops = 5;
for (int ctr = 0; ctr <= 4; ctr++)
thread_pool::queue_user_work_item(wait_callback {un_sync_update_resource});
thread_pool::queue_user_work_item(un_sync_update_resource);

// Wait until this WaitHandle is signaled.
ops_are_done.wait_one();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace wait_handle_example {
// wait until all tasks are completed.
auto dt = date_time::now();
console::write_line("Main thread is waiting for BOTH tasks to complete.");
thread_pool::queue_user_work_item(wait_callback(do_task), event1);
thread_pool::queue_user_work_item(wait_callback(do_task), event2);
thread_pool::queue_user_work_item(do_task, event1);
thread_pool::queue_user_work_item(do_task, event2);
wait_handle::wait_all({event1, event2});
// The time shown below should match the longest task.
console::write_line("Both tasks are completed (time waited={0})",
Expand All @@ -28,8 +28,8 @@ namespace wait_handle_example {
dt = date_time::now();
console::write_line();
console::write_line("The main thread is waiting for either task to complete.");
thread_pool::queue_user_work_item(wait_callback(do_task), event1);
thread_pool::queue_user_work_item(wait_callback(do_task), event2);
thread_pool::queue_user_work_item(do_task, event1);
thread_pool::queue_user_work_item(do_task, event2);
auto index = wait_handle::wait_any({event1, event2});
// The time shown below should match the shortest task.
console::write_line("Task {0} finished first (time waited={1}).",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class form1 : public form {
button_send.location({10, 10});
button_send.text("Send async notify something ready");
button_send.click += [&] {
thread_pool::queue_user_work_item(wait_callback {[&] {
thread_pool::queue_user_work_item([&] {
thread::sleep(2_s);
notifier.notify_something_ready();
}});
});
};

list_box_messages.location({10, 50});
Expand Down

0 comments on commit 4038801

Please sign in to comment.