Skip to content

Commit

Permalink
* NEW [iceoryx] Update the comments and fix some typo.
Browse files Browse the repository at this point in the history
Signed-off-by: wanghaemq <wangwei@emqx.io>
  • Loading branch information
wanghaEMQ committed Apr 4, 2024
1 parent a870226 commit d22896d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/supplemental/iceoryx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ if(NNG_ENABLE_ICEORYX)
nng_sources(iceoryx_api.h)

nng_test(iceoryx_api_test)
#nng_link_libraries(iceoryx_binding_c)
nng_link_libraries(iceoryx_binding_c::iceoryx_binding_c)
nng_link_libraries(iceoryx_binding_c::iceoryx_binding_c)
endif()
53 changes: 27 additions & 26 deletions src/supplemental/iceoryx/iceoryx_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ struct nano_iceoryx_puber {
int
nano_iceoryx_init(const char *const name)
{
iox_runtime_init(name); // No related to subscriber or publisher. just a runtime name
iox_runtime_init(name); // No related to subscriber or publisher. just a runtime name

if ((suber_map = nng_alloc(sizeof(*suber_map))) == NULL)
return NNG_ENOMEM;
nni_id_map_init(suber_map, 0, 0xffffffff, false);
Expand All @@ -49,15 +49,16 @@ int
nano_iceoryx_fini()
{
nni_id_map_fini(suber_map);
// TODO I don't know. It get stuck when shutdown.
// iox_runtime_shutdown();
return 0;
}

void
nano_iceoryx_listener_alloc(nano_iceoryx_listener **listenerp)
{
iox_listener_storage_t listener_storage;
iox_listener_t listener = iox_listener_init(&listener_storage);
iox_listener_storage_t listener_storage;
iox_listener_t listener = iox_listener_init(&listener_storage);

*listenerp = listener;
}
Expand All @@ -84,7 +85,7 @@ suber_recv_cb(iox_sub_t subscriber)
log_error("Failed to get msg from suber%d error%d", subscriber, rv);
return;
}
// Get description of this suber.
// XXX Get description of this suber.
// iox_service_description_t desc = iox_sub_get_service_description(subscriber);

rv = nni_lmq_put(suber->recvmq, (nng_msg *)msg);
Expand All @@ -100,23 +101,23 @@ nano_iceoryx_suber_alloc(const char *subername, const char *const service_name,
const char *const instance_name, const char *const event,
nano_iceoryx_listener *lstner)
{
iox_listener_t listener = lstner;
nano_iceoryx_suber *suber = nng_alloc(sizeof(*suber));
iox_listener_t listener = lstner;
nano_iceoryx_suber *suber = nng_alloc(sizeof(*suber));
if (!suber)
return NULL;

iox_sub_options_t options;
iox_sub_options_init(&options);
options.historyRequest = 10U;
options.queueCapacity = 50U;
options.nodeName = subername;
iox_sub_options_t options;
iox_sub_options_init(&options);
options.historyRequest = 10U;
options.queueCapacity = 50U;
options.nodeName = subername;

iox_sub_storage_t subscriber_storage;
iox_sub_t subscriber = iox_sub_init(&subscriber_storage, service_name,
instance_name, event, &options);
iox_sub_storage_t subscriber_storage;
iox_sub_t subscriber = iox_sub_init(
&subscriber_storage, service_name, instance_name, event, &options);

iox_listener_attach_subscriber_event(
(iox_listener_t)listener, subscriber, SubscriberEvent_DATA_RECEIVED, &suber_recv_cb);
iox_listener_attach_subscriber_event((iox_listener_t) listener,
subscriber, SubscriberEvent_DATA_RECEIVED, &suber_recv_cb);

suber->recvmq = nng_alloc(sizeof(*suber->recvmq));
if (suber->recvmq == NULL) {
Expand All @@ -142,9 +143,9 @@ nano_iceoryx_suber_alloc(const char *subername, const char *const service_name,
void
nano_iceoryx_suber_free(nano_iceoryx_suber *suber)
{
iox_listener_detach_subscriber_event(suber->listener, suber->suber,
iox_listener_detach_subscriber_event(suber->listener, suber->suber,
SubscriberEvent_DATA_RECEIVED);
iox_sub_deinit(suber->suber);
iox_sub_deinit(suber->suber);
nni_lmq_fini(suber->recvmq);
nng_free(suber->recvmq, sizeof(*suber->recvmq));
nng_free(suber, sizeof(*suber));
Expand All @@ -158,15 +159,15 @@ nano_iceoryx_puber_alloc(const char *pubername, const char *const service_name,
if (!puber)
return NULL;

iox_pub_options_t options;
iox_pub_options_init(&options);
options.historyCapacity = 10U;
options.nodeName = pubername;
iox_pub_options_t options;
iox_pub_options_init(&options);
options.historyCapacity = 10U;
options.nodeName = pubername;

iox_pub_storage_t publisher_storage;
iox_pub_storage_t publisher_storage;

iox_pub_t publisher = iox_pub_init(&publisher_storage, service_name,
instance_name, event, &options);
iox_pub_t publisher = iox_pub_init(
&publisher_storage, service_name, instance_name, event, &options);

puber->puber = publisher;
return puber;
Expand Down
9 changes: 9 additions & 0 deletions src/supplemental/iceoryx/iceoryx_api.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
//
// Copyright 2024 NanoMQ Team, Inc. <wangwei@emqx.io>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//

#ifndef NNG_SUPP_ICEORYX_API_H
#define NNG_SUPP_ICEORYX_API_H

Expand Down

0 comments on commit d22896d

Please sign in to comment.