lib/notify: rename spdk_notify_get_events to spdk_notify_foreach_event

And change type name of callback as well. The new name is more accurate.

Change-Id: I13b63f7d33f60ecea7fdf6e50f57aa6a391a4562
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453151
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
wuzhouhui 2019-05-05 18:20:43 +08:00 committed by Changpeng Liu
parent 87201f17d6
commit ab3f35b226
6 changed files with 14 additions and 12 deletions

View File

@ -10,8 +10,9 @@ receive queue is predicated on hardware support when this flag is not used.
### notify ### notify
The function `spdk_notify_get_types()` was renamed to `spdk_notify_foreach_type()`. The function `spdk_notify_get_types()` and `spdk_notify_get_events()` were
And update type name of callback accordingly. renamed to `spdk_notify_foreach_type()` and `spdk_notify_foreach_event()`,
respectively. And update type name of callback accordingly.
## v19.04: ## v19.04:

View File

@ -23,7 +23,7 @@ about notification.
# Get new events {#notify_listen} # Get new events {#notify_listen}
A consumer can get events by calling function `spdk_notify_get_events`. A consumer can get events by calling function `spdk_notify_foreach_event`.
The caller should specify last received event and the maximum number of invocations. The caller should specify last received event and the maximum number of invocations.
There might be multiple consumers of each event. The event bus is implemented as a There might be multiple consumers of each event. The event bus is implemented as a
circular buffer, so older events may be overwritten by newer ones. circular buffer, so older events may be overwritten by newer ones.

View File

@ -65,8 +65,8 @@ struct spdk_notify_event {
* \param ctx User context * \param ctx User context
* \return Non zero to break iteration. * \return Non zero to break iteration.
*/ */
typedef int (*spdk_notify_get_event_cb)(uint64_t idx, const struct spdk_notify_event *event, typedef int (*spdk_notify_foreach_event_cb)(uint64_t idx, const struct spdk_notify_event *event,
void *ctx); void *ctx);
/** /**
* Register \c type as new notification type. * Register \c type as new notification type.
@ -116,8 +116,8 @@ uint64_t spdk_notify_send(const char *type, const char *ctx);
* \param ctx User context * \param ctx User context
* \return Number of user callback invocations * \return Number of user callback invocations
*/ */
uint64_t spdk_notify_get_events(uint64_t start_idx, uint64_t max, spdk_notify_get_event_cb cb_fn, uint64_t spdk_notify_foreach_event(uint64_t start_idx, uint64_t max,
void *ctx); spdk_notify_foreach_event_cb cb_fn, void *ctx);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -121,7 +121,7 @@ spdk_rpc_get_notifications(struct spdk_jsonrpc_request *request,
} }
spdk_json_write_array_begin(req.w); spdk_json_write_array_begin(req.w);
spdk_notify_get_events(req.id, req.max, get_notifications_cb, &req); spdk_notify_foreach_event(req.id, req.max, get_notifications_cb, &req);
spdk_json_write_array_end(req.w); spdk_json_write_array_end(req.w);
spdk_jsonrpc_end_result(request, req.w); spdk_jsonrpc_end_result(request, req.w);

View File

@ -128,7 +128,8 @@ spdk_notify_send(const char *type, const char *ctx)
} }
uint64_t uint64_t
spdk_notify_get_events(uint64_t start_idx, uint64_t max, spdk_notify_get_event_cb cb_fn, void *ctx) spdk_notify_foreach_event(uint64_t start_idx, uint64_t max,
spdk_notify_foreach_event_cb cb_fn, void *ctx)
{ {
uint64_t i; uint64_t i;

View File

@ -68,14 +68,14 @@ notify(void)
spdk_notify_send("two", "two_context"); spdk_notify_send("two", "two_context");
event = NULL; event = NULL;
cnt = spdk_notify_get_events(0, 1, event_cb, &event); cnt = spdk_notify_foreach_event(0, 1, event_cb, &event);
SPDK_CU_ASSERT_FATAL(cnt == 1); SPDK_CU_ASSERT_FATAL(cnt == 1);
SPDK_CU_ASSERT_FATAL(event != NULL); SPDK_CU_ASSERT_FATAL(event != NULL);
CU_ASSERT(strcmp(event->type, "one") == 0); CU_ASSERT(strcmp(event->type, "one") == 0);
CU_ASSERT(strcmp(event->ctx, "one_context") == 0); CU_ASSERT(strcmp(event->ctx, "one_context") == 0);
event = NULL; event = NULL;
cnt = spdk_notify_get_events(1, 1, event_cb, &event); cnt = spdk_notify_foreach_event(1, 1, event_cb, &event);
SPDK_CU_ASSERT_FATAL(cnt == 1); SPDK_CU_ASSERT_FATAL(cnt == 1);
SPDK_CU_ASSERT_FATAL(event != NULL); SPDK_CU_ASSERT_FATAL(event != NULL);
CU_ASSERT(strcmp(event->type, "two") == 0); CU_ASSERT(strcmp(event->type, "two") == 0);
@ -83,7 +83,7 @@ notify(void)
/* This event should not exist yet */ /* This event should not exist yet */
event = NULL; event = NULL;
cnt = spdk_notify_get_events(2, 1, event_cb, &event); cnt = spdk_notify_foreach_event(2, 1, event_cb, &event);
CU_ASSERT(cnt == 0); CU_ASSERT(cnt == 0);
CU_ASSERT(event == NULL); CU_ASSERT(event == NULL);