mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
Arguments to Task are now forwarded to std::thread more correctly
Change-Id: I81a934a6fac4ead30c67010e9968e46ad2f86571
This commit is contained in:
@@ -42,6 +42,16 @@ ClassName(ClassName &&) = default
|
||||
#define DEPRECATED(msg) /*nothing*/
|
||||
#endif
|
||||
|
||||
// Provide std::decay_t when using GCC < 4.9
|
||||
#if defined(__GNUC__)
|
||||
#if __GNUC__ == 4 && __GNUC_MINOR__ < 9
|
||||
#include <type_traits>
|
||||
namespace std {
|
||||
template <class T> using decay_t = typename decay<T>::type;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// A struct to use as a deleter when a std::shared_ptr must wrap a raw pointer
|
||||
// that is being deleted by someone else.
|
||||
// This should only be called in deprecated functions; using it anywhere else
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* Wrapper class around std::thread that allows changing thread priority
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,8 @@ Task::Task(const std::string& name, Function&& function, Args&&... args) {
|
||||
|
||||
std::cout << "[HAL] Starting task " << m_taskName << "..." << std::endl;
|
||||
|
||||
m_thread = std::thread(function, args...);
|
||||
m_thread = std::thread(std::forward<std::decay_t<Function>>(function),
|
||||
std::forward<Args>(args)...);
|
||||
//TODO: lvuser does not currently have permissions to set the priority.
|
||||
//SetPriority(kDefaultPriority);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user