Skip to content

Thread: remove constructors deprecated in 5.1 #12141

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 24, 2019
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
152 changes: 0 additions & 152 deletions rtos/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,135 +125,6 @@ class Thread : private mbed::NonCopyable<Thread> {
}


/** Create a new thread, and start it executing the specified function.
@param task function to be executed by this thread.
@param priority initial priority of the thread function. (default: osPriorityNormal).
@param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
@param stack_mem pointer to the stack area to be used by this thread (default: nullptr).
@deprecated
Thread-spawning constructors hide errors. Replaced by thread.start(task).

@code
Thread thread(priority, stack_size, stack_mem);

osStatus status = thread.start(task);
if (status != osOK) {
error("oh no!");
}
@endcode

@note You cannot call this function from ISR context.
*/
MBED_DEPRECATED_SINCE("mbed-os-5.1",
"Thread-spawning constructors hide errors. "
"Replaced by thread.start(task).")
Thread(mbed::Callback<void()> task,
osPriority priority = osPriorityNormal,
uint32_t stack_size = OS_STACK_SIZE,
unsigned char *stack_mem = nullptr)
{
constructor(task, priority, stack_size, stack_mem);
}

/** Create a new thread, and start it executing the specified function.
@param argument pointer that is passed to the thread function as start argument. (default: nullptr).
@param task argument to task.
@param priority initial priority of the thread function. (default: osPriorityNormal).
@param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
@param stack_mem pointer to the stack area to be used by this thread (default: nullptr).
@deprecated
Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).

@code
Thread thread(priority, stack_size, stack_mem);

osStatus status = thread.start(callback(task, argument));
if (status != osOK) {
error("oh no!");
}
@endcode

@note You cannot call this function from ISR context.
*/
template <typename T>
MBED_DEPRECATED_SINCE("mbed-os-5.1",
"Thread-spawning constructors hide errors. "
"Replaced by thread.start(callback(task, argument)).")
Thread(T *argument, void (T::*task)(),
osPriority priority = osPriorityNormal,
uint32_t stack_size = OS_STACK_SIZE,
unsigned char *stack_mem = nullptr)
{
constructor(mbed::callback(task, argument),
priority, stack_size, stack_mem);
}

/** Create a new thread, and start it executing the specified function.
@param argument pointer that is passed to the thread function as start argument. (default: nullptr).
@param task argument to task.
@param priority initial priority of the thread function. (default: osPriorityNormal).
@param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
@param stack_mem pointer to the stack area to be used by this thread (default: nullptr).
@deprecated
Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).

@code
Thread thread(priority, stack_size, stack_mem);

osStatus status = thread.start(callback(task, argument));
if (status != osOK) {
error("oh no!");
}
@endcode

@note You cannot call this function from ISR context.
*/
template <typename T>
MBED_DEPRECATED_SINCE("mbed-os-5.1",
"Thread-spawning constructors hide errors. "
"Replaced by thread.start(callback(task, argument)).")
Thread(T *argument, void (*task)(T *),
osPriority priority = osPriorityNormal,
uint32_t stack_size = OS_STACK_SIZE,
unsigned char *stack_mem = nullptr)
{
constructor(mbed::callback(task, argument),
priority, stack_size, stack_mem);
}

/** Create a new thread, and start it executing the specified function.
Provided for backwards compatibility
@param task function to be executed by this thread.
@param argument pointer that is passed to the thread function as start argument. (default: nullptr).
@param priority initial priority of the thread function. (default: osPriorityNormal).
@param stack_size stack size (in bytes) requirements for the thread function. (default: OS_STACK_SIZE).
@param stack_mem pointer to the stack area to be used by this thread (default: nullptr).
@deprecated
Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).

@code
Thread thread(priority, stack_size, stack_mem);

osStatus status = thread.start(callback(task, argument));
if (status != osOK) {
error("oh no!");
}
@endcode

@note You cannot call this function from ISR context.
*/
MBED_DEPRECATED_SINCE("mbed-os-5.1",
"Thread-spawning constructors hide errors. "
"Replaced by thread.start(callback(task, argument)).")
Thread(void (*task)(void const *argument), void *argument = nullptr,
osPriority priority = osPriorityNormal,
uint32_t stack_size = OS_STACK_SIZE,
unsigned char *stack_mem = nullptr)
{
constructor(mbed::callback((void (*)(void *))task, argument),
priority, stack_size, stack_mem);
}

/** Starts a thread executing the specified function.
@param task function to be executed by this thread.
@return status code that indicates the execution status of the function.
Expand All @@ -263,24 +134,6 @@ class Thread : private mbed::NonCopyable<Thread> {
*/
osStatus start(mbed::Callback<void()> task);

/** Starts a thread executing the specified function.
@param obj argument to task
@param method function to be executed by this thread.
@return status code that indicates the execution status of the function.
@deprecated
The start function does not support cv-qualifiers. Replaced by start(callback(obj, method)).

@note You cannot call this function from ISR context.
*/
template <typename T, typename M>
MBED_DEPRECATED_SINCE("mbed-os-5.1",
"The start function does not support cv-qualifiers. "
"Replaced by thread.start(callback(obj, method)).")
osStatus start(T *obj, M method)
{
return start(mbed::callback(obj, method));
}

/** Wait for thread to terminate
@return status code that indicates the execution status of the function.

Expand Down Expand Up @@ -522,11 +375,6 @@ class Thread : private mbed::NonCopyable<Thread> {
uint32_t stack_size = OS_STACK_SIZE,
unsigned char *stack_mem = nullptr,
const char *name = nullptr);
void constructor(mbed::Callback<void()> task,
osPriority priority = osPriorityNormal,
uint32_t stack_size = OS_STACK_SIZE,
unsigned char *stack_mem = nullptr,
const char *name = nullptr);
void constructor(uint32_t tz_module,
osPriority priority = osPriorityNormal,
uint32_t stack_size = OS_STACK_SIZE,
Expand Down
19 changes: 0 additions & 19 deletions rtos/source/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,6 @@ void Thread::constructor(osPriority priority,
constructor(MBED_TZ_DEFAULT_ACCESS, priority, stack_size, stack_mem, name);
}

void Thread::constructor(mbed::Callback<void()> task,
osPriority priority, uint32_t stack_size, unsigned char *stack_mem, const char *name)
{
constructor(MBED_TZ_DEFAULT_ACCESS, priority, stack_size, stack_mem, name);

switch (start(task)) {
case osErrorResource:
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_RESOURCES), "OS ran out of threads!\n", task);
break;
case osErrorParameter:
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_ALREADY_IN_USE), "Thread already running!\n", task);
break;
case osErrorNoMemory:
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Error allocating the stack memory\n", task);
default:
break;
}
}

osStatus Thread::start(mbed::Callback<void()> task)
{
_mutex.lock();
Expand Down