DJI SDK 3.3 - 创建多线程
DJI SDK 3.3 - Create multiple threads
我想使用DJI OSDK 3.3创建线程。我在文件 posix_thread.cpp
中找到了 PosixThread 的定义,但由于我是 C++ 的新手,任何人都可以向我提供有关如何正确创建自定义线程的一些 hints/links 吗?
您不能使用 posix 线程 api。
您可以轻松地使用 std::thread.
这是一个 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));
}
}
我想使用DJI OSDK 3.3创建线程。我在文件 posix_thread.cpp
中找到了 PosixThread 的定义,但由于我是 C++ 的新手,任何人都可以向我提供有关如何正确创建自定义线程的一些 hints/links 吗?
您不能使用 posix 线程 api。 您可以轻松地使用 std::thread.
这是一个 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));
}
}