Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WaitSet detail classes [11656] #1989

Merged
merged 13 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refs 11608. WaitSetImpl with empty implementation.
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
  • Loading branch information
MiguelCompany committed May 26, 2021
commit 04ff2a1dea0f45d90c05208ccda516fbf6a7cad5
1 change: 1 addition & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ set(${PROJECT_NAME}_source_files
fastdds/core/condition/ConditionNotifier.cpp
fastdds/core/condition/StatusCondition.cpp
fastdds/core/condition/WaitSet.cpp
fastdds/core/condition/WaitSetImpl.cpp
fastdds/core/policy/ParameterList.cpp
fastdds/core/policy/QosPolicyUtils.cpp
fastdds/publisher/qos/WriterQos.cpp
Expand Down
75 changes: 75 additions & 0 deletions src/cpp/fastdds/core/condition/WaitSetImpl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file WaitSetImpl.cpp
*/

#include "WaitSetImpl.hpp"

#include <fastdds/dds/core/condition/Condition.hpp>
#include <fastdds/rtps/common/Time_t.h>
#include <fastrtps/types/TypesBase.h>

using eprosima::fastrtps::types::ReturnCode_t;

namespace eprosima {
namespace fastdds {
namespace dds {
namespace detail {

ReturnCode_t WaitSetImpl::attach_condition(
const Condition& condition)
{
static_cast<void>(condition);
return ReturnCode_t::RETCODE_UNSUPPORTED;
}

ReturnCode_t WaitSetImpl::detach_condition(
const Condition& condition)
{
static_cast<void>(condition);
return ReturnCode_t::RETCODE_UNSUPPORTED;
}

ReturnCode_t WaitSetImpl::wait(
ConditionSeq& active_conditions,
const fastrtps::Duration_t& timeout)
{
static_cast<void>(active_conditions);
static_cast<void>(timeout);
return ReturnCode_t::RETCODE_UNSUPPORTED;
}

ReturnCode_t WaitSetImpl::get_conditions(
ConditionSeq& attached_conditions) const
{
static_cast<void>(attached_conditions);
return ReturnCode_t::RETCODE_UNSUPPORTED;
}

void WaitSetImpl::wake_up()
{
}

void WaitSetImpl::will_be_deleted (
const Condition& condition)
{
static_cast<void>(condition);
}

} // namespace detail
} // namespace dds
} // namespace fastdds
} // namespace eprosima
90 changes: 90 additions & 0 deletions src/cpp/fastdds/core/condition/WaitSetImpl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file WaitSetImpl.hpp
*/

#ifndef _FASTDDS_CORE_CONDITION_WAITSETIMPL_HPP_
#define _FASTDDS_CORE_CONDITION_WAITSETIMPL_HPP_

#include <fastdds/dds/core/condition/Condition.hpp>
#include <fastdds/rtps/common/Time_t.h>
#include <fastrtps/types/TypesBase.h>

using eprosima::fastrtps::types::ReturnCode_t;

namespace eprosima {
namespace fastdds {
namespace dds {
namespace detail {

struct WaitSetImpl
{
/**
* @brief Attaches a Condition to this WaitSet implementation
JLBuenoLopez marked this conversation as resolved.
Show resolved Hide resolved
* @param condition The Condition to attach to this WaitSet implementation
* @return RETCODE_OK if attached correctly, error code otherwise
JLBuenoLopez marked this conversation as resolved.
Show resolved Hide resolved
*/
ReturnCode_t attach_condition(
const Condition& condition);

/**
* @brief Detaches a Condition from the WaitSet implementation
* @param condition The Condition to detach from this
* @return RETCODE_OK if detached correctly, PRECONDITION_NOT_MET if condition was not attached
*/
ReturnCode_t detach_condition(
const Condition& condition);

/**
* @brief Allows an application thread to wait for the occurrence of certain conditions.
* If none of the conditions attached to the WaitSet have a trigger_value of true,
* the wait operation will block suspending the calling thread
* @param active_conditions Reference to the collection of conditions which trigger_value are true
* @param timeout Maximum time of the wait
* @return RETCODE_OK if everything correct, PRECONDITION_NOT_MET if WaitSet already waiting, TIMEOUT if maximum
* time expired, error code otherwise
*/
ReturnCode_t wait(
ConditionSeq& active_conditions,
const fastrtps::Duration_t& timeout);

/**
* @brief Retrieves the list of attached conditions
* @param attached_conditions Reference to the collection of attached conditions
* @return RETCODE_OK if everything correct, error code otherwise
JLBuenoLopez marked this conversation as resolved.
Show resolved Hide resolved
*/
ReturnCode_t get_conditions(
ConditionSeq& attached_conditions) const;

/**
* @brief Wake up this WaitSet implementation if it was waiting
*/
void wake_up();

/**
* @brief Called from the destructor of a Condition to inform this WaitSet implementation that the condition
* should be automatically detached.
*/
void will_be_deleted (
const Condition& condition);
};

} // namespace detail
} // namespace dds
} // namespace fastdds
} // namespace eprosima

#endif // _FASTDDS_CORE_CONDITION_WAITSETIMPL_HPP_