Skip to content

Fix deprecated Thread ctor usage in RTOS tests #3490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions TESTS/mbedmicro-rtos-mbed/isr/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions TESTS/mbedmicro-rtos-mbed/mail/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down
12 changes: 7 additions & 5 deletions TESTS/mbedmicro-rtos-mbed/mutex/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions TESTS/mbedmicro-rtos-mbed/queue/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down
14 changes: 9 additions & 5 deletions TESTS/mbedmicro-rtos-mbed/semaphore/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions TESTS/mbedmicro-rtos-mbed/signals/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
19 changes: 12 additions & 7 deletions TESTS/mbedmicro-rtos-mbed/threads/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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();
}

Expand All @@ -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);
}
Expand All @@ -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++) {
Expand All @@ -92,16 +96,17 @@ 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();
}

TEST_ASSERT_EQUAL(counter, N);
}

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;
}
Expand Down