首页 > 代码库 > QThread的源码(直接搜索"thread.cpp"即可,或者在github里搜)
QThread的源码(直接搜索"thread.cpp"即可,或者在github里搜)
void QThread::run(){ (void) exec();}int QThread::exec(){ Q_D(QThread); QMutexLocker locker(&d->mutex); d->data->quitNow = false; if (d->exited) { d->exited = false; return d->returnCode; } locker.unlock(); QEventLoop eventLoop; int returnCode = eventLoop.exec(); locker.relock(); d->exited = false; d->returnCode = -1; return returnCode;}void QThread::exit(int returnCode){ Q_D(QThread); QMutexLocker locker(&d->mutex); d->exited = true; d->returnCode = returnCode; d->data->quitNow = true; for (int i = 0; i < d->data->eventLoops.size(); ++i) { QEventLoop *eventLoop = d->data->eventLoops.at(i); eventLoop->exit(returnCode); }}/*! Tells the thread‘s event loop to exit with return code 0 (success). Equivalent to calling QThread::exit(0). This function does nothing if the thread does not have an event loop. \sa exit(), QEventLoop*/void QThread::quit(){ exit(); }
https://github.com/openwebos/qt/blob/master/src/corelib/thread/qthread.cpp
QThread的源码(直接搜索"thread.cpp"即可,或者在github里搜)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。