RTI Connext Modern C++ API Version 7.3.0

Other Utilities, such as rti::util::spin() More...

Functions

void rti::util::sleep (const dds::core::Duration &durationIn)
 Blocks the calling thread for the specified duration. More...
 
uint64_t rti::util::spin_per_microsecond ()
 Returns the number of spin operations needed to wait 1 microsecond. More...
 
void rti::util::spin (uint64_t spin_count)
 Performs a spin operation (active wait) as many times as indicated. More...
 
bool rti::util::activation::unload_activation_library ()
 Unloads the Activation Library (rti_activation) if it was previously loaded. More...
 

Detailed Description

Other Utilities, such as rti::util::spin()

Function Documentation

◆ sleep()

void rti::util::sleep ( const dds::core::Duration durationIn)

Blocks the calling thread for the specified duration.

Note that the achievable resolution of sleep is OS-dependent. That is, do not assume that you can sleep for 1 nanosecond just because you can specify a 1-nanosecond sleep duration via the API. The sleep resolution on most operating systems is usually 10 ms or greater.

Parameters
durationIn<<in>> Sleep duration.
MT Safety:
safe
Examples
Foo_publisher.cxx.

◆ spin_per_microsecond()

uint64_t rti::util::spin_per_microsecond ( )

Returns the number of spin operations needed to wait 1 microsecond.

This utility can be used to measure how many spin operations must be performed to wait 1 microsecond. Since the time that it takes the CPU to perform 1 spin operation depends on the CPU frequency, it is recommended to use this utility before using spin().

Returns
Number of spin operations to wait 1 microsecond.
See also
rti::util::spin()

◆ spin()

void rti::util::spin ( uint64_t  spin_count)

Performs a spin operation (active wait) as many times as indicated.

Spinning is the action of performing useless operations in a for loop in order to actively wait some time without yielding the CPU. Given that the resolution of sleep is in the order of ms, you can use this utility to wait times in the order of microseconds. To properly use this functionality, it is useful to measure previously the number of spin operations needed to wait the equivalent to microsecond (using the utility get_spin_per_microsecond) and then compute the corresponding spin count desired.

Parameters
spin_count<<in>> Number of spin operations to perform.
See also
rti::util::spin_per_microsecond()

◆ unload_activation_library()

bool rti::util::activation::unload_activation_library ( )

Unloads the Activation Library (rti_activation) if it was previously loaded.

This function should be called just before your process finishes. See the License Management section in the Installation Guide for additional details.

Returns
true if successful. Otherwise, false