Skip to content

Commit 810c816

Browse files
committed
internal docs & explanations
1 parent 79835e4 commit 810c816

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

qmetaobject/src/future.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ static QT_WAKER_VTABLE: std::task::RawWakerVTable = unsafe {
3434
};
3535

3636
cpp! {{
37+
/// Special QObject subclass to glue together internals of Rust's futures and Qt's events.
38+
/// It's lifetime is determined through reference counting, and its lifecycle is based on
39+
/// Qt's QObject rather than C++ RAII.
3740
struct Waker : QObject {
41+
/// Wrapped Rust's Future as a dynamic trait object.
3842
TraitObject future;
43+
/// Guard against redundant processing of multiple consecutive wake-up calls.
3944
bool woken = false;
45+
/// Guard against polling a future after it has been completed.
4046
bool completed = false;
47+
/// Reference counter.
4148
QAtomicInt refs = 0;
4249

4350
void customEvent(QEvent *e) override {
@@ -69,6 +76,9 @@ cpp! {{
6976
return;
7077
}
7178
woken = true;
79+
// This line results in invocation of customEvent(QEvent*) method above.
80+
// Note that object may be waken multiple times before the wake up call
81+
// actually gets proceeded by the Qt's event loop.
7282
QApplication::postEvent(this, new QEvent(QEvent::User));
7383
}
7484

0 commit comments

Comments
 (0)