Skip to content
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

Deprecate CallChain and InterruptManager #5393

Merged
merged 2 commits into from
Nov 2, 2017
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
6 changes: 6 additions & 0 deletions drivers/InterruptManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
#include "cmsis.h"
#if defined(NVIC_NUM_VECTORS)

// Suppress deprecation warnings since this whole
// class is deprecated already
#include "mbed_toolchain.h"
#undef MBED_DEPRECATED_SINCE
#define MBED_DEPRECATED_SINCE(...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea 👍


#include "drivers/InterruptManager.h"
#include "platform/mbed_critical.h"
#include <string.h>
Expand Down
14 changes: 14 additions & 0 deletions drivers/InterruptManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ class InterruptManager : private NonCopyable<InterruptManager> {
*
* @return the only instance of this class
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
static InterruptManager* get();

/** Destroy the current instance of the interrupt manager
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
static void destroy();

/** Add a handler for an interrupt at the end of the handler list
Expand All @@ -74,6 +78,8 @@ class InterruptManager : private NonCopyable<InterruptManager> {
* @returns
* The function object created for 'function'
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
pFunctionPointer_t add_handler(void (*function)(void), IRQn_Type irq) {
// Underlying call is thread safe
return add_common(function, irq);
Expand All @@ -87,6 +93,8 @@ class InterruptManager : private NonCopyable<InterruptManager> {
* @returns
* The function object created for 'function'
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
pFunctionPointer_t add_handler_front(void (*function)(void), IRQn_Type irq) {
// Underlying call is thread safe
return add_common(function, irq, true);
Expand All @@ -102,6 +110,8 @@ class InterruptManager : private NonCopyable<InterruptManager> {
* The function object created for 'tptr' and 'mptr'
*/
template<typename T>
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
pFunctionPointer_t add_handler(T* tptr, void (T::*mptr)(void), IRQn_Type irq) {
// Underlying call is thread safe
return add_common(tptr, mptr, irq);
Expand All @@ -117,6 +127,8 @@ class InterruptManager : private NonCopyable<InterruptManager> {
* The function object created for 'tptr' and 'mptr'
*/
template<typename T>
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
pFunctionPointer_t add_handler_front(T* tptr, void (T::*mptr)(void), IRQn_Type irq) {
// Underlying call is thread safe
return add_common(tptr, mptr, irq, true);
Expand All @@ -130,6 +142,8 @@ class InterruptManager : private NonCopyable<InterruptManager> {
* @returns
* true if the handler was found and removed, false otherwise
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
bool remove_handler(pFunctionPointer_t handler, IRQn_Type irq);

private:
Expand Down
7 changes: 7 additions & 0 deletions platform/CallChain.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

// Suppress deprecation warnings since this whole
// class is deprecated already
#include "mbed_toolchain.h"
#undef MBED_DEPRECATED_SINCE
#define MBED_DEPRECATED_SINCE(...)

#include "platform/CallChain.h"
#include "cmsis.h"
#include "platform/mbed_critical.h"
Expand Down
26 changes: 26 additions & 0 deletions platform/CallChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ class CallChain : private NonCopyable<CallChain> {
*
* @param size (optional) Initial size of the chain
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
CallChain(int size = 4);

MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
virtual ~CallChain();

/** Add a function at the end of the chain
Expand All @@ -82,6 +87,8 @@ class CallChain : private NonCopyable<CallChain> {
* @returns
* The function object created for 'func'
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
pFunctionPointer_t add(Callback<void()> func);

/** Add a function at the end of the chain
Expand Down Expand Up @@ -111,6 +118,8 @@ class CallChain : private NonCopyable<CallChain> {
* @returns
* The function object created for 'func'
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
pFunctionPointer_t add_front(Callback<void()> func);

/** Add a function at the beginning of the chain
Expand All @@ -135,6 +144,8 @@ class CallChain : private NonCopyable<CallChain> {

/** Get the number of functions in the chain
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
int size() const;

/** Get a function object from the chain
Expand All @@ -144,6 +155,8 @@ class CallChain : private NonCopyable<CallChain> {
* @returns
* The function object at position 'i' in the chain
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
pFunctionPointer_t get(int i) const;

/** Look for a function object in the call chain
Expand All @@ -153,10 +166,14 @@ class CallChain : private NonCopyable<CallChain> {
* @returns
* The index of the function object if found, -1 otherwise.
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
int find(pFunctionPointer_t f) const;

/** Clear the call chain (remove all functions in the chain).
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
void clear();

/** Remove a function object from the chain
Expand All @@ -166,15 +183,24 @@ class CallChain : private NonCopyable<CallChain> {
* @returns
* true if the function object was found and removed, false otherwise.
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
bool remove(pFunctionPointer_t f);

/** Call all the functions in the chain in sequence
*/
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
void call();

MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
void operator ()(void) {
call();
}

MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
"public API of mbed-os and is being removed in the future.")
pFunctionPointer_t operator [](int i) const {
return get(i);
}
Expand Down