Skip to content

Commit

Permalink
iox-#751 Fix rpc c example by using iox_ws_mark_for_destruction
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Eltzschig <christian.eltzschig@apex.ai>
  • Loading branch information
elfenpiff committed Jun 23, 2022
1 parent ca632d5 commit 1c4ea5b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions iceoryx_examples/request_response_in_c/client_c_waitset.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "iceoryx_binding_c/request_header.h"
#include "iceoryx_binding_c/response_header.h"
#include "iceoryx_binding_c/runtime.h"
#include "iceoryx_binding_c/user_trigger.h"
#include "iceoryx_binding_c/wait_set.h"
#include "request_and_response_c_types.h"
#include "sleep_for.h"
Expand All @@ -32,10 +33,14 @@
bool keepRunning = true;
const char APP_NAME[] = "iox-c-request-response-client-waitset";

iox_ws_t waitset;
iox_ws_storage_t waitsetStorage;

void sigHandler(int signalValue)
{
(void)signalValue;
keepRunning = false;
iox_ws_mark_for_destruction(waitset);
}

int main()
Expand All @@ -54,7 +59,6 @@ int main()
int64_t expectedResponseSequenceId = requestSequenceId;

//! [create waitset and attach client]
iox_ws_storage_t waitsetStorage;
iox_ws_t waitset = iox_ws_init(&waitsetStorage);

if (iox_ws_attach_client_state(waitset, client, ClientState_HAS_RESPONSE, 0U, NULL) != WaitSetResult_SUCCESS)
Expand Down Expand Up @@ -132,8 +136,11 @@ int main()
}
//! [process responses]

const uint32_t SLEEP_TIME_IN_MS = 950U;
sleep_for(SLEEP_TIME_IN_MS);
if (keepRunning)
{
const uint32_t SLEEP_TIME_IN_MS = 950U;
sleep_for(SLEEP_TIME_IN_MS);
}
}

//! [cleanup]
Expand Down

0 comments on commit 1c4ea5b

Please sign in to comment.