Skip to content

Commit 1ef213e

Browse files
committed
Clean up Thread deprecation warnings
Static Thread methods and signal methods have been deprecated. Remove all references in the main code, and most of the tests. Some tests of the deprecated APIs themselves remain.
1 parent 8dcc949 commit 1ef213e

File tree

60 files changed

+159
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+159
-145
lines changed

TESTS/mbed_drivers/lp_ticker/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void test_multi_ticker(void)
7979
ticker[i].attach_us(callback(increment_multi_counter), MULTI_TICKER_TIME_MS * 1000);
8080
}
8181

82-
Thread::wait(MULTI_TICKER_TIME_MS + extra_wait);
82+
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + extra_wait);
8383
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
8484

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

98-
Thread::wait(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
98+
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
9999
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
100100

101101
for (int i = 0; i < TICKER_COUNT; i++) {

TESTS/mbed_drivers/mem_trace/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ static void test_case_multithread_malloc_free()
391391
threads[i].start(callback(malloc_free, &threads_continue));
392392
}
393393

394-
Thread::wait(wait_time_us);
394+
ThisThread::sleep_for(wait_time_us);
395395
threads_continue = false;
396396

397397
for (int i = 0; i < NUM_TEST_THREADS; i++) {

TESTS/mbed_drivers/race_test/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ class TestClass {
3939
public:
4040
TestClass()
4141
{
42-
Thread::wait(500);
42+
ThisThread::sleep_for(500);
4343
instance_count++;
4444
}
4545

4646
void do_something()
4747
{
48-
Thread::wait(100);
48+
ThisThread::sleep_for(100);
4949
}
5050

5151
~TestClass()
@@ -83,7 +83,7 @@ void test_case_func_race()
8383
// Start start first thread
8484
t1.start(cb);
8585
// Start second thread while the first is inside the constructor
86-
Thread::wait(250);
86+
ThisThread::sleep_for(250);
8787
t2.start(cb);
8888

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

111111
// Wait for the threads to finish

TESTS/mbed_drivers/ticker/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void test_multi_ticker(void)
195195
ticker[i].attach_us(callback(increment_multi_counter), MULTI_TICKER_TIME_MS * 1000);
196196
}
197197

198-
Thread::wait(MULTI_TICKER_TIME_MS + extra_wait);
198+
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + extra_wait);
199199
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
200200

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

214-
Thread::wait(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
214+
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
215215
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
216216

217217
for (int i = 0; i < TICKER_COUNT; i++) {

TESTS/mbed_drivers/timeout/timeout_tests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void test_multiple(void)
177177
for (size_t i = 0; i < NUM_TIMEOUTS; i++) {
178178
timeouts[i].attach_callback(mbed::callback(cnt_callback, &callback_count), TEST_DELAY_US);
179179
}
180-
Thread::wait(TEST_DELAY_MS + 2);
180+
ThisThread::sleep_for(TEST_DELAY_MS + 2);
181181
TEST_ASSERT_EQUAL(NUM_TIMEOUTS, callback_count);
182182
}
183183

TESTS/mbed_hal/sleep_manager_racecondition/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void sleep_manager_locking_thread_test()
3535
{
3636
for (uint32_t i = 0; i < 100; i++) {
3737
sleep_manager_lock_deep_sleep();
38-
Thread::wait(25);
38+
ThisThread::sleep_for(25);
3939
sleep_manager_unlock_deep_sleep();
4040
}
4141
}
@@ -48,7 +48,7 @@ void sleep_manager_multithread_test()
4848
Thread t2(osPriorityNormal, TEST_STACK_SIZE);
4949

5050
t1.start(callback(cb));
51-
Thread::wait(25);
51+
ThisThread::sleep_for(25);
5252
t2.start(callback(cb));
5353

5454
// Wait for the threads to finish

TESTS/mbed_platform/stats_cpu/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void get_cpu_usage()
5656
uint8_t usage = 100 - ((diff * 100) / (SAMPLE_TIME * 1000));
5757
prev_idle_time = stats.idle_time;
5858
TEST_ASSERT_NOT_EQUAL(0, usage);
59-
Thread::wait(SAMPLE_TIME);
59+
ThisThread::sleep_for(SAMPLE_TIME);
6060
}
6161
}
6262

@@ -65,7 +65,7 @@ void test_cpu_info(void)
6565
mbed_stats_cpu_t stats;
6666
// Additional read to make sure timer is initialized
6767
mbed_stats_cpu_get(&stats);
68-
Thread::wait(3);
68+
ThisThread::sleep_for(3);
6969
mbed_stats_cpu_get(&stats);
7070
TEST_ASSERT_NOT_EQUAL(0, stats.uptime);
7171
TEST_ASSERT_NOT_EQUAL(0, stats.idle_time);
@@ -83,7 +83,7 @@ void test_cpu_load(void)
8383

8484
// Steadily increase the system load
8585
for (int count = 1; ; count++) {
86-
Thread::wait(LOOP_TIME);
86+
ThisThread::sleep_for(LOOP_TIME);
8787
if (wait_time <= 0) {
8888
break;
8989
}

TESTS/mbed_platform/stats_thread/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void increment_with_delay()
4646
{
4747
while (1) {
4848
counter++;
49-
Thread::wait(500);
49+
ThisThread::sleep_for(500);
5050
}
5151
}
5252

@@ -111,7 +111,7 @@ void test_case_multi_threads_blocked()
111111
uint32_t ret = ef.set(FLAG_SIGNAL_DEC);
112112
TEST_ASSERT_FALSE(ret & osFlagsError);
113113

114-
Thread::wait(100);
114+
ThisThread::sleep_for(100);
115115

116116
count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS);
117117
TEST_ASSERT_EQUAL(1, (count - old_count));

TESTS/mbedmicro-rtos-mbed/basic/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ static const int test_timeout = 40;
4848
void update_tick_thread(Mutex *mutex)
4949
{
5050
while (true) {
51-
Thread::wait(1);
51+
ThisThread::sleep_for(1);
5252
mutex->lock();
5353
++elapsed_time_ms;
5454
mutex->unlock();
5555
}
5656
}
5757

5858

59-
/** Tests is to measure the accuracy of Thread::wait() over a period of time
59+
/** Tests is to measure the accuracy of ThisThread::sleep_for() over a period of time
6060
6161
Given
6262
a thread updating elapsed_time_ms every milli sec
@@ -109,7 +109,7 @@ void test(void)
109109
}
110110

111111
Case cases[] = {
112-
Case("Test Thread::wait accuracy", test)
112+
Case("Test ThisThread::sleep_for accuracy", test)
113113
};
114114

115115
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)

TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void send_thread(EventFlags *ef)
7575
const uint32_t flag = flags & (1 << i);
7676
if (flag) {
7777
ef->set(flag);
78-
Thread::wait(wait_ms);
78+
ThisThread::sleep_for(wait_ms);
7979
}
8080
}
8181
}
@@ -88,7 +88,7 @@ void send_thread_sync(EventFlags *ef)
8888
if (flag) {
8989
sync_sem.wait();
9090
ef->set(flag);
91-
Thread::wait(wait_ms);
91+
ThisThread::sleep_for(wait_ms);
9292
}
9393
}
9494
}

0 commit comments

Comments
 (0)