[英]DJI SDK 3.3 - Create multiple threads
I want to create threads using the DJI OSDK 3.3. 我想使用DJI OSDK 3.3创建线程。 I located the definition of PosixThread in the file posix_thread.cpp
, but since I am rather new to C++, could anyone provide me with some hints/links on how to properly create a custom thread ? 我在文件posix_thread.cpp中找到了posix_thread.cpp
的定义,但是由于我对C ++ posix_thread.cpp
,因此有人可以为我提供一些有关如何正确创建自定义线程的提示/链接吗?
You're not gated to use the posix thread apis. 您没有被限制使用posix线程api。 You can easily use the std::thread . 您可以轻松使用std :: thread 。
Here is a small runloop-style sample. 这是一个小的runloop样式示例。
void
RunLoop::start()
{
this->asyncThread = std::thread(&RunLoop::asyncStart, this);
}
void
RunLoop::asyncStart()
{
while (this->shouldRun)
{
// Timer's executions
this->evaluateTimers();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.