1 year ago
#341334
sadeq
QObject singleton living on main thread, invoke it's signal from another thread, is it thread safe?
as the title says,
I have a Core
singleton that inherits from QObject
that is constructed on the main thread.
I also Have a QTcpServer
that is creating a new QThread
for each new connection, that is where I serve Http Requests.
sometimes I need to invoke a signal called newMessage(...)
that belongs to the Core
singleton from an Http request handler thread, the purpose is to notify a QWebSocket
server living on the main thread to propagate the event to the connected websockets.
so it's like
HttpResponse HttpController::callback(HttpRequest *request){
//a callback of an object living inside a handler thread
//some code
emit Core::instance()->newMessage(...) //this object is living on the main thread
//do some work
//return HttpResponse(...)
}
multithreading
qt
qthread
qt-signals
qobject
0 Answers
Your Answer