You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example port in #70 uncovered an issue: that MIQT is currently missing functions that can transport a callback onto the main thread.
Draft plan
Possible ideas:
moveToThread
QCoreApplication::postEvent
Emits are allowed cross-thread ⭐
Add cpp:
#include<QObject>classsignaller : publicQObject {
Q_OBJECT
private:do_self_emit_blocking(handle) {
emit please_run_blocking(handle);
}
do_self_emit_async(handle) {
emit please_run_async(handle);
}
signals:
voidplease_run_blocking(handle);
voidplease_run_async(handle);
public:static signaller* singleton() {
static signaller instance;
return &instance;
}
Qt::HANDLE main_thread_id;
staticvoiddo_on_main_thread_async(handle) {
// Always async, no need to run the callback ourselvessingleton()->do_self_emit_async(handle)
}
staticvoiddo_on_main_thread_blocking(handle) {
if (QThread::currentThreadId() == main_thread_id) {
// Call it ourselves to avoid deadlockmiqt_exec_callback(handle);
} else {
singleton()->do_self_emit_blocking(handle)
}
}
}
n.b. needs pre-MOC:
/usr/lib/qt5/bin/moc --help
/usr/lib/qt6/libexec/moc --help
CABI: After constructing QMainApplication:
// signal comes from another thread, so use queuedconnectionsignaller::singleton()->main_thread_id = QThread::currentThreadId();
connect(signaller::singleton(), please_run_blocking, this, [=](handle) {
miqt_exec_callback(handle);
}, Qt::BlockingQueuedConnection);
connect(signaller::singleton(), please_run_async, this, [=](handle) {
miqt_exec_callback(handle);
}, Qt::QueuedConnection);
The example port in #70 uncovered an issue: that MIQT is currently missing functions that can transport a callback onto the main thread.
Draft plan
Possible ideas:
Add cpp:
n.b. needs pre-MOC:
/usr/lib/qt5/bin/moc --help
/usr/lib/qt6/libexec/moc --help
CABI: After constructing QMainApplication:
The Go interface:
The text was updated successfully, but these errors were encountered: