-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix read_next_sample and take_next_sample (#1899)
This is a port of #1732 from <master> to <2.2.x> * Refs 10476. Fix on DataReaderTests. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Added xxx_next_sample tests to DataReaderTests.read_unread Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Strict real-time on read_or_take. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Using LoanableTypedCollection<SampleInfo> on ReadTakeCommand and DataReaderLoanManager. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Use ReadTakeCommand on take_next_sample. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Use ReadTakeCommand on read_next_sample via read_or_take_next_sample. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Adapt tests to new behavior of take Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 10476. Added method get_first_change_with_minimum_ts to ReaderHistory. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Add new method to mock. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. PubSubReader::last_seq is now a map for each instance. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Added UserAllocatedSequence. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Added take_first_data to PubSubReader. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Using take_first_data on LifespanQos blackbox test. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Uncrustify. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10476. Solve build error on non-windows platforms. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> * Refs 10480. Apply suggestions from code review Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> Co-authored-by: IkerLuengo <57146230+IkerLuengo@users.noreply.github.com> Co-authored-by: Iker Luengo <ikerluengo@eprosima.com> Co-authored-by: IkerLuengo <57146230+IkerLuengo@users.noreply.github.com> Signed-off-by: Iker Luengo <ikerluengo@eprosima.com>
- Loading branch information
1 parent
da33604
commit 12fdf42
Showing
14 changed files
with
355 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// 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 UserAllocatedSequence.hpp | ||
*/ | ||
|
||
#ifndef _FASTDDS_DDS_CORE_USERALLOCATEDSEQUENCE_HPP_ | ||
#define _FASTDDS_DDS_CORE_USERALLOCATEDSEQUENCE_HPP_ | ||
|
||
#include <cassert> | ||
#include <cstdint> | ||
#include <stdexcept> | ||
|
||
#include <fastdds/dds/core/LoanableCollection.hpp> | ||
|
||
namespace eprosima { | ||
namespace fastdds { | ||
namespace dds { | ||
|
||
/** | ||
* A collection of generic opaque pointers allocated by the user. | ||
* | ||
* This kind of collection would always return @c true for @c has_ownership(), | ||
* and thus would not be able to receive loans. | ||
* It would also have an inmutable @c maximum(), so it would not allow @c length() to grow beyond the maximum | ||
* value indicated on construction. | ||
*/ | ||
struct UserAllocatedSequence : public LoanableCollection | ||
{ | ||
using size_type = LoanableCollection::size_type; | ||
using element_type = LoanableCollection::element_type; | ||
|
||
/** | ||
* Construct a UserAllocatedSequence. | ||
* | ||
* @param [in] items Pointer to the beginning of an array of @c num_items opaque pointers. | ||
* @param [in] num_items Number of opaque pointers in @c items. | ||
* | ||
* @post buffer() == items | ||
* @post has_ownership() == true | ||
* @post length() == 0 | ||
* @post maximum() == num_items | ||
*/ | ||
UserAllocatedSequence( | ||
element_type* items, | ||
size_type num_items) | ||
{ | ||
has_ownership_ = true; | ||
maximum_ = num_items; | ||
length_ = 0; | ||
elements_ = items; | ||
} | ||
|
||
~UserAllocatedSequence() = default; | ||
|
||
// Non-copyable | ||
UserAllocatedSequence( | ||
const UserAllocatedSequence&) = delete; | ||
UserAllocatedSequence& operator = ( | ||
const UserAllocatedSequence&) = delete; | ||
|
||
// Non-moveable | ||
UserAllocatedSequence( | ||
UserAllocatedSequence&&) = delete; | ||
UserAllocatedSequence& operator = ( | ||
UserAllocatedSequence&&) = delete; | ||
|
||
protected: | ||
|
||
using LoanableCollection::maximum_; | ||
using LoanableCollection::length_; | ||
using LoanableCollection::elements_; | ||
using LoanableCollection::has_ownership_; | ||
|
||
void resize( | ||
size_type new_length) override | ||
{ | ||
// This kind of collection cannot grow above its stack-allocated size | ||
if (new_length > maximum_) | ||
{ | ||
throw std::bad_alloc(); | ||
} | ||
} | ||
|
||
}; | ||
|
||
} // namespace dds | ||
} // namespace fastdds | ||
} // namespace eprosima | ||
|
||
#endif // _FASTDDS_DDS_CORE_USERALLOCATEDSEQUENCE_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.