Skip to content

Commit

Permalink
iox-#27 Make the underlying type of enums unsigned to simplify deseri…
Browse files Browse the repository at this point in the history
…alization
  • Loading branch information
elBoberido committed Jan 6, 2022
1 parent f36dd81 commit 908deea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum class QueueFullPolicy : uint8_t
};

/// @brief Used by producers how to adjust to slow consumer
enum class ConsumerTooSlowPolicy
enum class ConsumerTooSlowPolicy : uint8_t
{
/// Waits for the consumer it it's queue is full
WAIT_FOR_CONSUMER,
Expand All @@ -49,7 +49,7 @@ enum class ConsumerTooSlowPolicy

/// @brief Used by consumers to request a specific behavior from the producer
/// @todo iox-#27 Rename this to QueueFullPolicy
enum class QueueFullPolicy2
enum class QueueFullPolicy2 : uint8_t
{
/// Requests the producer to block when the consumer queue is full
BLOCK_PRODUCER,
Expand Down
13 changes: 3 additions & 10 deletions iceoryx_posh/source/popo/server_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,13 @@ ServerOptions::deserialize(const cxx::Serialization& serialized) noexcept
auto deserializationSuccessful = serialized.extract(
serverOptions.requestQueueCapacity, serverOptions.nodeName, serverOptions.offerOnCreate, clientTooSlowPolicy);

if (!deserializationSuccessful)
{
return cxx::error<cxx::Serialization::Error>(cxx::Serialization::Error::DESERIALIZATION_FAILED);
}

if (clientTooSlowPolicy < 0
if (!deserializationSuccessful
|| clientTooSlowPolicy > static_cast<ClientTooSlowPolicyUT>(ConsumerTooSlowPolicy::DISCARD_OLDEST_DATA))
{
return cxx::error<cxx::Serialization::Error>(cxx::Serialization::Error::DESERIALIZATION_FAILED);
}
else
{
serverOptions.clientTooSlowPolicy = static_cast<ConsumerTooSlowPolicy>(clientTooSlowPolicy);
}

serverOptions.clientTooSlowPolicy = static_cast<ConsumerTooSlowPolicy>(clientTooSlowPolicy);

return cxx::success<ServerOptions>(serverOptions);
}
Expand Down

0 comments on commit 908deea

Please sign in to comment.