From cf28457e2f2229b4a5ceba43a42bd49a75ef5c88 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Mon, 9 Dec 2019 12:32:15 +0200 Subject: [PATCH 1/2] Callback: nullptr adjustments Adjust wording to talk of Callback's being "empty", which is clearer than "null", and avoids thought of `NULL`. Add explicit note about using `nullptr` to reset. Preparation for https://github.com/ARMmbed/mbed-os/pull/12036 - can be merged now as adjustments are valid for existing code. --- docs/api/platform/Callback.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/api/platform/Callback.md b/docs/api/platform/Callback.md index 21a95681e1..ad22c31cfb 100644 --- a/docs/api/platform/Callback.md +++ b/docs/api/platform/Callback.md @@ -14,7 +14,7 @@ void run_timer_event(Callback on_timer) { } ``` -The only thing to watch out for is that the Callback type has a null Callback, just like a null function pointer. Uninitialized callbacks are null and assert if you call them. If you want a call to always succeed, you need to check if it is null first. +The only thing to watch out for is that the Callback type has an empty Callback, just like a null function pointer. Default initialized callbacks are empty and assert if you call them. If a callback may be empty, you need to check if it is empty before calling it. ``` c++ void run_timer_event(Callback on_timer) { @@ -24,6 +24,8 @@ void run_timer_event(Callback on_timer) { } ``` +Callbacks can be reset to empty by assigning `nullptr`. + The Callback class is what’s known in C++ as a “Concrete Type”. That is, the Callback class is lightweight enough to be passed around like an int, pointer or other primitive type. ## Callback class reference From 2edff81643dfab0e5f3b73390cac171aae6bbe9a Mon Sep 17 00:00:00 2001 From: Amanda Butler Date: Wed, 18 Dec 2019 11:41:20 -0600 Subject: [PATCH 2/2] Edit Callback.md Tweak phrasing for active voice. --- docs/api/platform/Callback.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/platform/Callback.md b/docs/api/platform/Callback.md index ad22c31cfb..84fc4f13b4 100644 --- a/docs/api/platform/Callback.md +++ b/docs/api/platform/Callback.md @@ -24,7 +24,7 @@ void run_timer_event(Callback on_timer) { } ``` -Callbacks can be reset to empty by assigning `nullptr`. +You can reset Callbacks to empty by assigning `nullptr`. The Callback class is what’s known in C++ as a “Concrete Type”. That is, the Callback class is lightweight enough to be passed around like an int, pointer or other primitive type.