mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #3490 from ARMmbed/fix_deprecated_thread_ctors
Fix deprecated Thread ctor usage in RTOS testspull/3514/head
commit
306cc1ab6d
|
@ -40,7 +40,7 @@ void queue_isr() {
|
|||
myled = !myled;
|
||||
}
|
||||
|
||||
void queue_thread(void const *argument) {
|
||||
void queue_thread() {
|
||||
while (true) {
|
||||
queue.put((uint32_t*)QUEUE_PUT_THREAD_VALUE);
|
||||
Thread::wait(THREAD_DELAY);
|
||||
|
@ -50,7 +50,8 @@ void queue_thread(void const *argument) {
|
|||
int main (void) {
|
||||
GREENTEA_SETUP(20, "default_auto");
|
||||
|
||||
Thread thread(queue_thread, NULL, osPriorityNormal, STACK_SIZE);
|
||||
Thread thread(osPriorityNormal, STACK_SIZE);
|
||||
thread.start(queue_thread);
|
||||
Ticker ticker;
|
||||
ticker.attach(queue_isr, 1.0);
|
||||
int isr_puts_counter = 0;
|
||||
|
|
|
@ -38,7 +38,7 @@ typedef struct {
|
|||
|
||||
Mail<mail_t, QUEUE_SIZE> mail_box;
|
||||
|
||||
void send_thread (void const *argument) {
|
||||
void send_thread () {
|
||||
static uint32_t i = 10;
|
||||
while (true) {
|
||||
i++; // fake data update
|
||||
|
@ -54,7 +54,8 @@ void send_thread (void const *argument) {
|
|||
int main (void) {
|
||||
GREENTEA_SETUP(20, "default_auto");
|
||||
|
||||
Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE);
|
||||
Thread thread(osPriorityNormal, STACK_SIZE);
|
||||
thread.start(send_thread);
|
||||
bool result = true;
|
||||
int result_counter = 0;
|
||||
|
||||
|
|
|
@ -77,10 +77,9 @@ bool manipulate_protected_zone(const int thread_delay) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void test_thread(void const *args) {
|
||||
const int thread_delay = int(args);
|
||||
void test_thread(int const *thread_delay) {
|
||||
while (true) {
|
||||
manipulate_protected_zone(thread_delay);
|
||||
manipulate_protected_zone(*thread_delay);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,8 +89,11 @@ int main() {
|
|||
const int t1_delay = THREAD_DELAY * 1;
|
||||
const int t2_delay = THREAD_DELAY * 2;
|
||||
const int t3_delay = THREAD_DELAY * 3;
|
||||
Thread t2(test_thread, (void *)t2_delay, osPriorityNormal, STACK_SIZE);
|
||||
Thread t3(test_thread, (void *)t3_delay, osPriorityNormal, STACK_SIZE);
|
||||
Thread t2(osPriorityNormal, STACK_SIZE);
|
||||
Thread t3(osPriorityNormal, STACK_SIZE);
|
||||
|
||||
t2.start(callback(test_thread, &t2_delay));
|
||||
t3.start(callback(test_thread, &t3_delay));
|
||||
|
||||
while (true) {
|
||||
// Thread 1 action
|
||||
|
|
|
@ -40,7 +40,7 @@ MemoryPool<message_t, QUEUE_SIZE> mpool;
|
|||
Queue<message_t, QUEUE_SIZE> queue;
|
||||
|
||||
/* Send Thread */
|
||||
void send_thread (void const *argument) {
|
||||
void send_thread () {
|
||||
static uint32_t i = 10;
|
||||
while (true) {
|
||||
i++; // Fake data update
|
||||
|
@ -56,7 +56,8 @@ void send_thread (void const *argument) {
|
|||
int main (void) {
|
||||
GREENTEA_SETUP(20, "default_auto");
|
||||
|
||||
Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE);
|
||||
Thread thread(osPriorityNormal, STACK_SIZE);
|
||||
thread.start(send_thread);
|
||||
bool result = true;
|
||||
int result_counter = 0;
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ volatile int change_counter = 0;
|
|||
volatile int sem_counter = 0;
|
||||
volatile bool sem_defect = false;
|
||||
|
||||
void test_thread(void const *delay) {
|
||||
const int thread_delay = int(delay);
|
||||
void test_thread(int const *delay) {
|
||||
const int thread_delay = *delay;
|
||||
while (true) {
|
||||
two_slots.wait();
|
||||
sem_counter++;
|
||||
|
@ -81,9 +81,13 @@ int main (void) {
|
|||
const int t1_delay = THREAD_DELAY * 1;
|
||||
const int t2_delay = THREAD_DELAY * 2;
|
||||
const int t3_delay = THREAD_DELAY * 3;
|
||||
Thread t1(test_thread, (void *)t1_delay, osPriorityNormal, STACK_SIZE);
|
||||
Thread t2(test_thread, (void *)t2_delay, osPriorityNormal, STACK_SIZE);
|
||||
Thread t3(test_thread, (void *)t3_delay, osPriorityNormal, STACK_SIZE);
|
||||
Thread t1(osPriorityNormal, STACK_SIZE);
|
||||
Thread t2(osPriorityNormal, STACK_SIZE);
|
||||
Thread t3(osPriorityNormal, STACK_SIZE);
|
||||
|
||||
t1.start(callback(test_thread, &t1_delay));
|
||||
t2.start(callback(test_thread, &t2_delay));
|
||||
t3.start(callback(test_thread, &t3_delay));
|
||||
|
||||
while (true) {
|
||||
if (change_counter >= SEM_CHANGES or sem_defect == true) {
|
||||
|
|
|
@ -32,7 +32,7 @@ const int SIGNAL_HANDLE_DELEY = 25;
|
|||
DigitalOut led(LED1);
|
||||
int signal_counter = 0;
|
||||
|
||||
void led_thread(void const *argument) {
|
||||
void led_thread() {
|
||||
while (true) {
|
||||
// Signal flags that are reported as event are automatically cleared.
|
||||
Thread::signal_wait(SIGNAL_SET_VALUE);
|
||||
|
@ -44,7 +44,8 @@ void led_thread(void const *argument) {
|
|||
int main (void) {
|
||||
GREENTEA_SETUP(20, "default_auto");
|
||||
|
||||
Thread thread(led_thread, NULL, osPriorityNormal, STACK_SIZE);
|
||||
Thread thread(osPriorityNormal, STACK_SIZE);
|
||||
thread.start(led_thread);
|
||||
bool result = false;
|
||||
|
||||
printf("Handling %d signals...\r\n", SIGNALS_TO_EMIT);
|
||||
|
|
|
@ -39,7 +39,8 @@ void increment_with_wait(counter_t* counter) {
|
|||
}
|
||||
|
||||
void increment_with_child(counter_t* counter) {
|
||||
Thread child(counter, increment);
|
||||
Thread child;
|
||||
child.start(callback(increment, counter));
|
||||
child.join();
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,8 @@ void increment_with_murder(counter_t* counter) {
|
|||
// take ownership of the counter mutex so it prevent the child to
|
||||
// modify counter.
|
||||
LockGuard lock(counter->internal_mutex());
|
||||
Thread child(counter, increment);
|
||||
Thread child;
|
||||
child.start(callback(increment, counter));
|
||||
child.terminate();
|
||||
}
|
||||
|
||||
|
@ -65,7 +67,8 @@ void self_terminate(Thread *self) {
|
|||
template <void (*F)(counter_t *)>
|
||||
void test_single_thread() {
|
||||
counter_t counter(0);
|
||||
Thread thread(&counter, F);
|
||||
Thread thread;
|
||||
thread.start(callback(F, &counter));
|
||||
thread.join();
|
||||
TEST_ASSERT_EQUAL(counter, 1);
|
||||
}
|
||||
|
@ -76,7 +79,8 @@ void test_parallel_threads() {
|
|||
Thread *threads[N];
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
threads[i] = new Thread(&counter, F, osPriorityNormal, PARALLEL_STACK_SIZE);
|
||||
threads[i] = new Thread(osPriorityNormal, PARALLEL_STACK_SIZE);
|
||||
threads[i]->start(callback(F, &counter));
|
||||
}
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
|
@ -92,7 +96,8 @@ void test_serial_threads() {
|
|||
counter_t counter(0);
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
Thread thread(&counter, F);
|
||||
Thread thread;
|
||||
thread.start(callback(F, &counter));
|
||||
thread.join();
|
||||
}
|
||||
|
||||
|
@ -100,8 +105,8 @@ void test_serial_threads() {
|
|||
}
|
||||
|
||||
void test_self_terminate() {
|
||||
Thread *thread = new Thread(osPriorityNormal);
|
||||
thread->start(thread, self_terminate);
|
||||
Thread *thread = new Thread();
|
||||
thread->start(callback(self_terminate, thread));
|
||||
thread->join();
|
||||
delete thread;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue