RTI Connext .Net APIs  Version 6.0.1
DDS::LoanableSequence< E > Class Template Referenceabstract

A sequence implementation used internally by the middleware to efficiently manage memory during DDS::TypedDataReader::read and DDS::TypedDataReader::take operations. More...

#include <managed_sequence.h>

Inheritance diagram for DDS::LoanableSequence< E >:
DDS::Sequence< E >

Public Member Functions

virtual E get_at (System::Int32 i) override sealed
 Get the i-th element for a const sequence. More...
 
virtual System::Boolean copy_from_no_alloc (Sequence< E >^ src) override sealed
 Copy elements from another sequence, only if the destination sequence has enough capacity. More...
 
virtual void unloan () override sealed
 Return the loaned buffer in the sequence and set the maximum to 0. More...
 
- Public Member Functions inherited from DDS::Sequence< E >
System::Boolean ensure_length (System::Int32 length, System::Int32 max)
 Set the sequence to the desired length, and resize the sequence if necessary. More...
 
virtual void set_at (System::Int32 i, E val)
 Set the i-th element of the sequence. More...
 
void loan (array< E >^ buffer, System::Int32 new_length)
 Loan a contiguous buffer to this sequence. More...
 
void from_array (array< E >^ arr)
 Copy elements from an array of elements, resizing the sequence if necessary. The original contents of the sequence (if any) are replaced. More...
 
void to_array (array< E >^ arr)
 Copy elements to an array of elements. The original contents of the array (if any) are replaced. More...
 
System::Boolean copy_from (Sequence< E >^ src_seq)
 Copy elements from another sequence, resizing the sequence if necessary. More...
 

Additional Inherited Members

- Properties inherited from DDS::Sequence< E >
System::Int32 length [get, set]
 The logical length of this sequence. More...
 
virtual System::Int32 maximum [get, set]
 The current maximum number of elements that can be stored in this sequence. More...
 
array< E >^ buffer [get]
 Return the contiguous buffer of the sequence. More...
 
System::Boolean has_ownership [get]
 Return the value of the owned flag. More...
 

Detailed Description

template<typename E>
class DDS::LoanableSequence< E >

A sequence implementation used internally by the middleware to efficiently manage memory during DDS::TypedDataReader::read and DDS::TypedDataReader::take operations.

Applications are not expected to use this type directly.

Member Function Documentation

◆ get_at()

template<typename E>
virtual E DDS::LoanableSequence< E >::get_at ( System::Int32  i)
overridesealedvirtual

Get the i-th element for a const sequence.

Parameters
iindex of element to access, must be >= 0 and less than DDS::Sequence::length
Returns
the i-th element

Reimplemented from DDS::Sequence< E >.

Referenced by RTI.Connext.Infrastructure.LoanedSamples< T >::Remove().

◆ copy_from_no_alloc()

template<typename E>
virtual System::Boolean DDS::LoanableSequence< E >::copy_from_no_alloc ( Sequence< E >^  src_seq)
overridesealedvirtual

Copy elements from another sequence, only if the destination sequence has enough capacity.

Fill the elements in this sequence by copying the corresponding elements in src_seq. The original contents in this sequence are replaced via the element assignment operation (Foo_copy() function). By default, elements are discarded; 'delete' is not invoked on the discarded elements.

Precondition
this::maximum >= src_seq::length
this::owned == true
Postcondition
this::length == src_seq::length
this[i] == src_seq[i] for 0 <= i < target_seq::length
this::owned == true
Parameters
src_seq<<in>> the sequence from which to copy
Returns
true if the sequence was successfully copied; false otherwise.
Note
If the pre-conditions are not met, the operator will print a message to stdout and leave this sequence unchanged.
See also
DDS::Sequence::copy_from_no_alloc(DDS::Sequence<T>^)

Reimplemented from DDS::Sequence< E >.

◆ unloan()

template<typename E>
virtual void DDS::LoanableSequence< E >::unloan ( )
overridesealedvirtual

Return the loaned buffer in the sequence and set the maximum to 0.

This method affects only the state of this sequence; it does not change the contents of the buffer in any way.

Only the user who originally loaned a buffer should return that loan, as the user may have dependencies on that memory known only to them. Unloaning someone else's buffer may cause unspecified problems. For example, suppose a sequence is loaning memory from a custom memory pool. A user of the sequence likely has no way to release the memory back into the pool, so unloaning the sequence buffer would result in a resource leak. If the user were to then re-loan a different buffer, the original creator of the sequence would have no way to discover, when freeing the sequence, that the loan no longer referred to its own memory and would thus not free the user's memory properly, exacerbating the situation and leading to undefined behavior.

Precondition
owned == false
Postcondition
owned == true
maximum == 0
Returns
true if the preconditions were met. Otherwise false. The function only fails if the pre-conditions are not met, in which case it leaves the sequence unmodified.
See also
DDS::Sequence<T>::loan(array<T>^, System::Int32), DDS::Sequence::maximum

Reimplemented from DDS::Sequence< E >.


RTI Connext .Net APIs Version 6.0.1 Copyright © Sat Nov 23 2019 Real-Time Innovations, Inc