mirror of https://github.com/ARMmbed/mbed-os.git
callback - Reordered optional argument to static C function
Before: Callback<void()> a = callback(obj, member) Callback<void()> b = callback(context, function) After: Callback<void()> a = callback(obj, member) Callback<void()> b = callback(function, context) This ordering is more intuitive based on feedback from users. This order was initially considered but proved problematic when integrated with other variable arguments in attach functions. With `callback` as a separate convenience function, this style no longer presents a problem.pull/2794/head
parent
e9c556d356
commit
b371eb5269
5155
hal/api/Callback.h
5155
hal/api/Callback.h
File diff suppressed because it is too large
Load Diff
|
@ -47,7 +47,7 @@ public:
|
||||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||||
"Replaced with RtosTimer(Callback<void()>, os_timer_type)")
|
"Replaced with RtosTimer(Callback<void()>, os_timer_type)")
|
||||||
RtosTimer(void (*func)(void const *argument), os_timer_type type=osTimerPeriodic, void *argument=NULL) {
|
RtosTimer(void (*func)(void const *argument), os_timer_type type=osTimerPeriodic, void *argument=NULL) {
|
||||||
constructor(mbed::callback(argument, (void (*)(void *))func), type);
|
constructor(mbed::callback((void (*)(void *))func, argument), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create timer.
|
/** Create timer.
|
||||||
|
|
|
@ -108,12 +108,12 @@ public:
|
||||||
@param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
|
@param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
|
||||||
@param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
|
@param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
|
||||||
@deprecated
|
@deprecated
|
||||||
Thread-spawning constructors hide errors. Replaced by thread.start(callback(argument, task)).
|
Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
|
||||||
|
|
||||||
@code
|
@code
|
||||||
Thread thread(priority, stack_size, stack_pointer);
|
Thread thread(priority, stack_size, stack_pointer);
|
||||||
|
|
||||||
osStatus status = thread.start(callback(argument, task));
|
osStatus status = thread.start(callback(task, argument));
|
||||||
if (status != osOK) {
|
if (status != osOK) {
|
||||||
error("oh no!");
|
error("oh no!");
|
||||||
}
|
}
|
||||||
|
@ -122,12 +122,12 @@ public:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||||
"Thread-spawning constructors hide errors. "
|
"Thread-spawning constructors hide errors. "
|
||||||
"Replaced by thread.start(callback(argument, task)).")
|
"Replaced by thread.start(callback(task, argument)).")
|
||||||
Thread(T *argument, void (T::*task)(),
|
Thread(T *argument, void (T::*task)(),
|
||||||
osPriority priority=osPriorityNormal,
|
osPriority priority=osPriorityNormal,
|
||||||
uint32_t stack_size=DEFAULT_STACK_SIZE,
|
uint32_t stack_size=DEFAULT_STACK_SIZE,
|
||||||
unsigned char *stack_pointer=NULL) {
|
unsigned char *stack_pointer=NULL) {
|
||||||
constructor(mbed::callback(argument, task),
|
constructor(mbed::callback(task, argument),
|
||||||
priority, stack_size, stack_pointer);
|
priority, stack_size, stack_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,12 +139,12 @@ public:
|
||||||
@param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
|
@param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
|
||||||
@param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
|
@param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
|
||||||
@deprecated
|
@deprecated
|
||||||
Thread-spawning constructors hide errors. Replaced by thread.start(callback(argument, task)).
|
Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
|
||||||
|
|
||||||
@code
|
@code
|
||||||
Thread thread(priority, stack_size, stack_pointer);
|
Thread thread(priority, stack_size, stack_pointer);
|
||||||
|
|
||||||
osStatus status = thread.start(callback(argument, task));
|
osStatus status = thread.start(callback(task, argument));
|
||||||
if (status != osOK) {
|
if (status != osOK) {
|
||||||
error("oh no!");
|
error("oh no!");
|
||||||
}
|
}
|
||||||
|
@ -153,12 +153,12 @@ public:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||||
"Thread-spawning constructors hide errors. "
|
"Thread-spawning constructors hide errors. "
|
||||||
"Replaced by thread.start(callback(argument, task)).")
|
"Replaced by thread.start(callback(task, argument)).")
|
||||||
Thread(T *argument, void (*task)(T *),
|
Thread(T *argument, void (*task)(T *),
|
||||||
osPriority priority=osPriorityNormal,
|
osPriority priority=osPriorityNormal,
|
||||||
uint32_t stack_size=DEFAULT_STACK_SIZE,
|
uint32_t stack_size=DEFAULT_STACK_SIZE,
|
||||||
unsigned char *stack_pointer=NULL) {
|
unsigned char *stack_pointer=NULL) {
|
||||||
constructor(mbed::callback(argument, task),
|
constructor(mbed::callback(task, argument),
|
||||||
priority, stack_size, stack_pointer);
|
priority, stack_size, stack_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,12 +170,12 @@ public:
|
||||||
@param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
|
@param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
|
||||||
@param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
|
@param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
|
||||||
@deprecated
|
@deprecated
|
||||||
Thread-spawning constructors hide errors. Replaced by thread.start(callback(argument, task)).
|
Thread-spawning constructors hide errors. Replaced by thread.start(callback(task, argument)).
|
||||||
|
|
||||||
@code
|
@code
|
||||||
Thread thread(priority, stack_size, stack_pointer);
|
Thread thread(priority, stack_size, stack_pointer);
|
||||||
|
|
||||||
osStatus status = thread.start(callback(argument, task));
|
osStatus status = thread.start(callback(task, argument));
|
||||||
if (status != osOK) {
|
if (status != osOK) {
|
||||||
error("oh no!");
|
error("oh no!");
|
||||||
}
|
}
|
||||||
|
@ -183,12 +183,12 @@ public:
|
||||||
*/
|
*/
|
||||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||||
"Thread-spawning constructors hide errors. "
|
"Thread-spawning constructors hide errors. "
|
||||||
"Replaced by thread.start(callback(argument, task)).")
|
"Replaced by thread.start(callback(task, argument)).")
|
||||||
Thread(void (*task)(void const *argument), void *argument=NULL,
|
Thread(void (*task)(void const *argument), void *argument=NULL,
|
||||||
osPriority priority=osPriorityNormal,
|
osPriority priority=osPriorityNormal,
|
||||||
uint32_t stack_size=DEFAULT_STACK_SIZE,
|
uint32_t stack_size=DEFAULT_STACK_SIZE,
|
||||||
unsigned char *stack_pointer=NULL) {
|
unsigned char *stack_pointer=NULL) {
|
||||||
constructor(mbed::callback(argument, (void (*)(void *))task),
|
constructor(mbed::callback((void (*)(void *))task, argument),
|
||||||
priority, stack_size, stack_pointer);
|
priority, stack_size, stack_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue