@@ -39,7 +39,8 @@ void increment_with_wait(counter_t* counter) {
3939}
4040
4141void increment_with_child (counter_t * counter) {
42- Thread child (counter, increment);
42+ Thread child;
43+ child.start (callback (increment, counter));
4344 child.join ();
4445}
4546
@@ -48,7 +49,8 @@ void increment_with_murder(counter_t* counter) {
4849 // take ownership of the counter mutex so it prevent the child to
4950 // modify counter.
5051 LockGuard lock (counter->internal_mutex ());
51- Thread child (counter, increment);
52+ Thread child;
53+ child.start (callback (increment, counter));
5254 child.terminate ();
5355 }
5456
@@ -65,7 +67,8 @@ void self_terminate(Thread *self) {
6567template <void (*F)(counter_t *)>
6668void test_single_thread () {
6769 counter_t counter (0 );
68- Thread thread (&counter, F);
70+ Thread thread;
71+ thread.start (callback (F, &counter));
6972 thread.join ();
7073 TEST_ASSERT_EQUAL (counter, 1 );
7174}
@@ -76,7 +79,8 @@ void test_parallel_threads() {
7679 Thread *threads[N];
7780
7881 for (int i = 0 ; i < N; i++) {
79- threads[i] = new Thread (&counter, F, osPriorityNormal, PARALLEL_STACK_SIZE);
82+ threads[i] = new Thread (osPriorityNormal, PARALLEL_STACK_SIZE);
83+ threads[i]->start (callback (F, &counter));
8084 }
8185
8286 for (int i = 0 ; i < N; i++) {
@@ -92,16 +96,17 @@ void test_serial_threads() {
9296 counter_t counter (0 );
9397
9498 for (int i = 0 ; i < N; i++) {
95- Thread thread (&counter, F);
99+ Thread thread;
100+ thread.start (callback (F, &counter));
96101 thread.join ();
97102 }
98103
99104 TEST_ASSERT_EQUAL (counter, N);
100105}
101106
102107void test_self_terminate () {
103- Thread *thread = new Thread (osPriorityNormal );
104- thread->start (thread, self_terminate );
108+ Thread *thread = new Thread ();
109+ thread->start (callback (self_terminate, thread) );
105110 thread->join ();
106111 delete thread;
107112}
0 commit comments