gpt4 book ai didi

c++ - thread.cpp 的 handleRun 的空函数

转载 作者:行者123 更新时间:2023-11-28 07:35:19 25 4
gpt4 key购买 nike

#ifndef FFMPEG_THREAD_H
#define FFMPEG_THREAD_H

#include <pthread.h>

class Thread
{
public:
Thread();
~Thread();

void start();
void startAsync();
int wait();

void waitOnNotify();
void notify();
virtual void stop();

protected:
bool mRunning;

virtual void handleRun(void* ptr);

private:
pthread_t mThread;
pthread_mutex_t mLock;
pthread_cond_t mCondition;

static void* startThread(void* ptr);
};

#endif //FFMPEG_DECODER_H



void* Thread::startThread(void* ptr)
{

Thread* thread = (Thread *) ptr;
thread->mRunning = true;
thread->handleRun(ptr);
thread->mRunning = false;

}

void Thread::handleRun(void* ptr)
{
}

在这段代码中,thread.cpp。在线程对象内部,它开始运行并具有 HandleRun 函数,但它是空的。 HandleRun 空函数的目的是什么?它什么都不做。

最佳答案

您没有显示足够的代码来给出明确的答案。猜测,Thread 可能是 handleRunvirtual 的基类。

Thread 派生的类可能会自动创建一个专用线程,使用 handleRun 作为其入口点。

关于c++ - thread.cpp 的 handleRun 的空函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16863236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com