Skip to content

Clean up rtos::Thread deprecation warnings #7980

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
Oct 15, 2018
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
4 changes: 2 additions & 2 deletions TESTS/mbed_drivers/lp_ticker/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void test_multi_ticker(void)
ticker[i].attach_us(callback(increment_multi_counter), MULTI_TICKER_TIME_MS * 1000);
}

Thread::wait(MULTI_TICKER_TIME_MS + extra_wait);
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + extra_wait);
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);

for (int i = 0; i < TICKER_COUNT; i++) {
Expand All @@ -95,7 +95,7 @@ void test_multi_ticker(void)
ticker[i].attach_us(callback(increment_multi_counter), (MULTI_TICKER_TIME_MS + i) * 1000);
}

Thread::wait(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);

for (int i = 0; i < TICKER_COUNT; i++) {
Expand Down
2 changes: 1 addition & 1 deletion TESTS/mbed_drivers/mem_trace/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static void test_case_multithread_malloc_free()
threads[i].start(callback(malloc_free, &threads_continue));
}

Thread::wait(wait_time_us);
ThisThread::sleep_for(wait_time_us);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I note in passing that this takes milliseconds not microseconds. I wonder if this is supposed to run for 10 seconds or 10 milliseconds? Not changing it in this PR, anyway.

threads_continue = false;

for (int i = 0; i < NUM_TEST_THREADS; i++) {
Expand Down
8 changes: 4 additions & 4 deletions TESTS/mbed_drivers/race_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class TestClass {
public:
TestClass()
{
Thread::wait(500);
ThisThread::sleep_for(500);
instance_count++;
}

void do_something()
{
Thread::wait(100);
ThisThread::sleep_for(100);
}

~TestClass()
Expand Down Expand Up @@ -83,7 +83,7 @@ void test_case_func_race()
// Start start first thread
t1.start(cb);
// Start second thread while the first is inside the constructor
Thread::wait(250);
ThisThread::sleep_for(250);
t2.start(cb);

// Wait for the threads to finish
Expand All @@ -105,7 +105,7 @@ void test_case_class_race()
// Start start first thread
t1.start(cb);
// Start second thread while the first is inside the constructor
Thread::wait(250);
ThisThread::sleep_for(250);
t2.start(cb);

// Wait for the threads to finish
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbed_drivers/ticker/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void test_multi_ticker(void)
ticker[i].attach_us(callback(increment_multi_counter), MULTI_TICKER_TIME_MS * 1000);
}

Thread::wait(MULTI_TICKER_TIME_MS + extra_wait);
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + extra_wait);
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);

for (int i = 0; i < TICKER_COUNT; i++) {
Expand All @@ -211,7 +211,7 @@ void test_multi_ticker(void)
ticker[i].attach_us(callback(increment_multi_counter), (MULTI_TICKER_TIME_MS + i) * 1000);
}

Thread::wait(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);

for (int i = 0; i < TICKER_COUNT; i++) {
Expand Down
2 changes: 1 addition & 1 deletion TESTS/mbed_drivers/timeout/timeout_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void test_multiple(void)
for (size_t i = 0; i < NUM_TIMEOUTS; i++) {
timeouts[i].attach_callback(mbed::callback(cnt_callback, &callback_count), TEST_DELAY_US);
}
Thread::wait(TEST_DELAY_MS + 2);
ThisThread::sleep_for(TEST_DELAY_MS + 2);
TEST_ASSERT_EQUAL(NUM_TIMEOUTS, callback_count);
}

Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbed_hal/sleep_manager_racecondition/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void sleep_manager_locking_thread_test()
{
for (uint32_t i = 0; i < 100; i++) {
sleep_manager_lock_deep_sleep();
Thread::wait(25);
ThisThread::sleep_for(25);
sleep_manager_unlock_deep_sleep();
}
}
Expand All @@ -48,7 +48,7 @@ void sleep_manager_multithread_test()
Thread t2(osPriorityNormal, TEST_STACK_SIZE);

t1.start(callback(cb));
Thread::wait(25);
ThisThread::sleep_for(25);
t2.start(callback(cb));

// Wait for the threads to finish
Expand Down
6 changes: 3 additions & 3 deletions TESTS/mbed_platform/stats_cpu/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void get_cpu_usage()
uint8_t usage = 100 - ((diff * 100) / (SAMPLE_TIME * 1000));
prev_idle_time = stats.idle_time;
TEST_ASSERT_NOT_EQUAL(0, usage);
Thread::wait(SAMPLE_TIME);
ThisThread::sleep_for(SAMPLE_TIME);
}
}

Expand All @@ -65,7 +65,7 @@ void test_cpu_info(void)
mbed_stats_cpu_t stats;
// Additional read to make sure timer is initialized
mbed_stats_cpu_get(&stats);
Thread::wait(3);
ThisThread::sleep_for(3);
mbed_stats_cpu_get(&stats);
TEST_ASSERT_NOT_EQUAL(0, stats.uptime);
TEST_ASSERT_NOT_EQUAL(0, stats.idle_time);
Expand All @@ -83,7 +83,7 @@ void test_cpu_load(void)

// Steadily increase the system load
for (int count = 1; ; count++) {
Thread::wait(LOOP_TIME);
ThisThread::sleep_for(LOOP_TIME);
if (wait_time <= 0) {
break;
}
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbed_platform/stats_thread/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void increment_with_delay()
{
while (1) {
counter++;
Thread::wait(500);
ThisThread::sleep_for(500);
}
}

Expand Down Expand Up @@ -111,7 +111,7 @@ void test_case_multi_threads_blocked()
uint32_t ret = ef.set(FLAG_SIGNAL_DEC);
TEST_ASSERT_FALSE(ret & osFlagsError);

Thread::wait(100);
ThisThread::sleep_for(100);

count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS);
TEST_ASSERT_EQUAL(1, (count - old_count));
Expand Down
6 changes: 3 additions & 3 deletions TESTS/mbedmicro-rtos-mbed/basic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ static const int test_timeout = 40;
void update_tick_thread(Mutex *mutex)
{
while (true) {
Thread::wait(1);
ThisThread::sleep_for(1);
mutex->lock();
++elapsed_time_ms;
mutex->unlock();
}
}


/** Tests is to measure the accuracy of Thread::wait() over a period of time
/** Tests is to measure the accuracy of ThisThread::sleep_for() over a period of time

Given
a thread updating elapsed_time_ms every milli sec
Expand Down Expand Up @@ -109,7 +109,7 @@ void test(void)
}

Case cases[] = {
Case("Test Thread::wait accuracy", test)
Case("Test ThisThread::sleep_for accuracy", test)
};

utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void send_thread(EventFlags *ef)
const uint32_t flag = flags & (1 << i);
if (flag) {
ef->set(flag);
Thread::wait(wait_ms);
ThisThread::sleep_for(wait_ms);
}
}
}
Expand All @@ -88,7 +88,7 @@ void send_thread_sync(EventFlags *ef)
if (flag) {
sync_sem.wait();
ef->set(flag);
Thread::wait(wait_ms);
ThisThread::sleep_for(wait_ms);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion TESTS/mbedmicro-rtos-mbed/heap_and_stack/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void test_heap_allocation_free(void)
check_and_free_heap(head, max_allocation_size);

// Force a task switch so a stack check is performed
Thread::wait(10);
ThisThread::sleep_for(10);

printf("Total size dynamically allocated: %luB\n", max_allocation_size);
}
Expand Down
10 changes: 5 additions & 5 deletions TESTS/mbedmicro-rtos-mbed/mail/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void send_thread(Mail<mail_t, QUEUE_SIZE> *m)
mail->thread_id = thread_id;
mail->data = data++;
m->put(mail);
Thread::wait(wait_ms);
ThisThread::sleep_for(wait_ms);
}
}

Expand All @@ -72,7 +72,7 @@ void receive_thread(Mail<mail_t, queue_size> *m)
int result_counter = 0;
uint32_t data = thread_id * DATA_BASE;

Thread::wait(wait_ms);
ThisThread::sleep_for(wait_ms);
for (uint32_t i = 0; i < queue_size; i++) {
osEvent evt = m->get();
if (evt.status == osEventMail) {
Expand Down Expand Up @@ -108,7 +108,7 @@ void test_single_thread_order(void)
thread.start(callback(send_thread<THREAD_1_ID, QUEUE_PUT_DELAY_1, QUEUE_SIZE>, &mail_box));

// wait for some mail to be collected
Thread::wait(10);
ThisThread::sleep_for(10);

for (uint32_t i = 0; i < QUEUE_SIZE; i++) {
// mail receive (main thread)
Expand Down Expand Up @@ -150,7 +150,7 @@ void test_multi_thread_order(void)
thread3.start(callback(send_thread<THREAD_3_ID, QUEUE_PUT_DELAY_3, 4>, &mail_box));

// wait for some mail to be collected
Thread::wait(10);
ThisThread::sleep_for(10);

for (uint32_t i = 0; i < QUEUE_SIZE; i++) {
// mail receive (main thread)
Expand Down Expand Up @@ -211,7 +211,7 @@ void test_multi_thread_multi_mail_order(void)
mail->data = data[id]++;
mail_box[id].put(mail);

Thread::wait(i * 10);
ThisThread::sleep_for(i * 10);
}

thread1.join();
Expand Down
2 changes: 1 addition & 1 deletion TESTS/mbedmicro-rtos-mbed/malloc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void test_multithread_allocation(void)

// Give the test time to run
while (test_time--) {
Thread::wait(1000);
ThisThread::sleep_for(1000);
}

// Join and delete all threads
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbedmicro-rtos-mbed/mutex/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool manipulate_protected_zone(const int thread_delay)
change_counter++;
core_util_critical_section_exit();

Thread::wait(thread_delay);
ThisThread::sleep_for(thread_delay);

core_util_critical_section_enter();
changing_counter = false;
Expand Down Expand Up @@ -100,7 +100,7 @@ void test_multiple_threads(void)

while (true) {
// Thread 1 action
Thread::wait(t1_delay);
ThisThread::sleep_for(t1_delay);
manipulate_protected_zone(t1_delay);

core_util_critical_section_enter();
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbedmicro-rtos-mbed/queue/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ using namespace utest::v1;
template <uint32_t ms>
void thread_put_uint_msg(Queue<uint32_t, 1> *q)
{
Thread::wait(ms);
ThisThread::sleep_for(ms);
osStatus stat = q->put((uint32_t *) TEST_UINT_MSG);
TEST_ASSERT_EQUAL(osOK, stat);
}

template <uint32_t ms, uint32_t val>
void thread_get_uint_msg(Queue<uint32_t, 1> *q)
{
Thread::wait(ms);
ThisThread::sleep_for(ms);
osEvent evt = q->get();
TEST_ASSERT_EQUAL(osEventMessage, evt.status);
TEST_ASSERT_EQUAL(val, evt.value.v);
Expand Down
8 changes: 4 additions & 4 deletions TESTS/mbedmicro-rtos-mbed/semaphore/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void test_thread(int const *delay)
if (sem_lock_failed) {
sem_defect = true;
}
Thread::wait(thread_delay);
ThisThread::sleep_for(thread_delay);
sem_counter--;
change_counter++;
two_slots.release();
Expand Down Expand Up @@ -123,15 +123,15 @@ void test_single_thread()

res = t.start(callback(single_thread, &data));
TEST_ASSERT_EQUAL(osOK, res);
Thread::wait(SHORT_WAIT);
ThisThread::sleep_for(SHORT_WAIT);

TEST_ASSERT_EQUAL(Thread::WaitingSemaphore, t.get_state());
TEST_ASSERT_EQUAL(0, data.data);

res = sem.release();
TEST_ASSERT_EQUAL(osOK, res);

Thread::wait(SHORT_WAIT);
ThisThread::sleep_for(SHORT_WAIT);

TEST_ASSERT_EQUAL(1, data.data);

Expand Down Expand Up @@ -160,7 +160,7 @@ void test_timeout()
timer.start();
res = t.start(callback(timeout_thread, &sem));
TEST_ASSERT_EQUAL(osOK, res);
Thread::wait(SHORT_WAIT);
ThisThread::sleep_for(SHORT_WAIT);

TEST_ASSERT_EQUAL(Thread::WaitingSemaphore, t.get_state());

Expand Down
8 changes: 4 additions & 4 deletions TESTS/mbedmicro-rtos-mbed/signals/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void run_wait_clear(Sync *sync)
{
sync->sem_parent.release();
sync->sem_child.wait();
int32_t ret = Thread::signal_clr(signals);
int32_t ret = ThisThread::flags_clear(signals);
TEST_ASSERT_EQUAL(test_val, ret);
}

Expand All @@ -114,10 +114,10 @@ void run_double_wait_clear(Sync *sync)

sync->sem_parent.release();
sync->sem_child.wait();
ret = Thread::signal_clr(signals1);
ret = ThisThread::flags_clear(signals1);
TEST_ASSERT_EQUAL(test_val1, ret);

ret = Thread::signal_clr(signals2);
ret = ThisThread::flags_clear(signals2);
TEST_ASSERT_EQUAL(test_val2, ret);
}

Expand All @@ -128,7 +128,7 @@ void run_loop_wait_clear(Sync *sync)
int32_t signal = 1 << i;
signals |= signal;
sync->sem_child.wait();
int32_t ret = Thread::signal_clr(NO_SIGNALS);
int32_t ret = ThisThread::flags_clear(NO_SIGNALS);
TEST_ASSERT_EQUAL(signals, ret);
sync->sem_parent.release();
}
Expand Down
4 changes: 2 additions & 2 deletions TESTS/mbedmicro-rtos-mbed/threads/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ void test_thread_wait()
Timer timer;
timer.start();

Thread::wait(150);
ThisThread::sleep_for(150);

TEST_ASSERT_UINT32_WITHIN(50000, 150000, timer.read_us());
}
Expand Down Expand Up @@ -528,7 +528,7 @@ void test_deleted()

void test_delay_thread()
{
Thread::wait(50);
ThisThread::sleep_for(50);
}

/** Testing thread states: wait delay
Expand Down
2 changes: 1 addition & 1 deletion TESTS/netsocket/tcp/tcpsocket_echotest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void TCPSOCKET_ECHOTEST_NONBLOCK()

tcpsocket_connect_to_echo_srv(sock);
sock.set_blocking(false);
sock.sigio(callback(_sigio_handler, Thread::gettid()));
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));

int bytes2send;
int sent;
Expand Down
Loading