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:
parent
87201f17d6
commit
ab3f35b226
@ -10,8 +10,9 @@ receive queue is predicated on hardware support when this flag is not used.
|
||||
|
||||
### notify
|
||||
|
||||
The function `spdk_notify_get_types()` was renamed to `spdk_notify_foreach_type()`.
|
||||
And update type name of callback accordingly.
|
||||
The function `spdk_notify_get_types()` and `spdk_notify_get_events()` were
|
||||
renamed to `spdk_notify_foreach_type()` and `spdk_notify_foreach_event()`,
|
||||
respectively. And update type name of callback accordingly.
|
||||
|
||||
## v19.04:
|
||||
|
||||
|
@ -23,7 +23,7 @@ about notification.
|
||||
|
||||
# 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.
|
||||
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.
|
||||
|
@ -65,8 +65,8 @@ struct spdk_notify_event {
|
||||
* \param ctx User context
|
||||
* \return Non zero to break iteration.
|
||||
*/
|
||||
typedef int (*spdk_notify_get_event_cb)(uint64_t idx, const struct spdk_notify_event *event,
|
||||
void *ctx);
|
||||
typedef int (*spdk_notify_foreach_event_cb)(uint64_t idx, const struct spdk_notify_event *event,
|
||||
void *ctx);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* \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,
|
||||
void *ctx);
|
||||
uint64_t spdk_notify_foreach_event(uint64_t start_idx, uint64_t max,
|
||||
spdk_notify_foreach_event_cb cb_fn, void *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ spdk_rpc_get_notifications(struct spdk_jsonrpc_request *request,
|
||||
}
|
||||
|
||||
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_jsonrpc_end_result(request, req.w);
|
||||
|
@ -128,7 +128,8 @@ spdk_notify_send(const char *type, const char *ctx)
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -68,14 +68,14 @@ notify(void)
|
||||
spdk_notify_send("two", "two_context");
|
||||
|
||||
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(event != NULL);
|
||||
CU_ASSERT(strcmp(event->type, "one") == 0);
|
||||
CU_ASSERT(strcmp(event->ctx, "one_context") == 0);
|
||||
|
||||
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(event != NULL);
|
||||
CU_ASSERT(strcmp(event->type, "two") == 0);
|
||||
@ -83,7 +83,7 @@ notify(void)
|
||||
|
||||
/* This event should not exist yet */
|
||||
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(event == NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user