Skip to content

Commit

Permalink
propery deprecate the old style
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Nachtigall committed Nov 28, 2024
1 parent b5642d7 commit ed2fbfe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/realtime_tools/realtime_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ bool has_realtime_kernel();
*/
bool configure_sched_fifo(int priority);

/**
* Locks the memory pages of the calling thread to prevent page faults.
* By calling this method, the programs locks all pages mapped into the address
* space of the calling process and future mappings. This means that the kernel
* will not swap out the pages to disk i.e., the pages are guaranteed to stay in
* RAM until later unlocked - which is important for realtime applications.
* \param[out] message a message describing the result of the operation
* \returns a pair of a boolean indicating whether the operation succeeded or not.
*/

[[deprecated("Use std::pair<bool, std::string> lock_memory() instead.")]]
bool lock_memory(std::string & message);

/**
* Locks the memory pages of the calling thread to prevent page faults.
* By calling this method, the programs locks all pages mapped into the address
Expand Down
7 changes: 7 additions & 0 deletions src/realtime_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ bool configure_sched_fifo(int priority)
#endif
}

bool lock_memory(std::string & message)
{
const auto lock_result = lock_memory();
message = lock_result.second;
return lock_result.first;
}

std::pair<bool, std::string> lock_memory()
{
#ifdef _WIN32
Expand Down

0 comments on commit ed2fbfe

Please sign in to comment.