File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -34,10 +34,17 @@ static QT_WAKER_VTABLE: std::task::RawWakerVTable = unsafe {
34
34
} ;
35
35
36
36
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.
37
40
struct Waker : QObject {
41
+ /// Wrapped Rust's Future as a dynamic trait object.
38
42
TraitObject future;
43
+ /// Guard against redundant processing of multiple consecutive wake-up calls.
39
44
bool woken = false ;
45
+ /// Guard against polling a future after it has been completed.
40
46
bool completed = false ;
47
+ /// Reference counter.
41
48
QAtomicInt refs = 0 ;
42
49
43
50
void customEvent( QEvent * e) override {
@@ -69,6 +76,9 @@ cpp! {{
69
76
return ;
70
77
}
71
78
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.
72
82
QApplication :: postEvent( this, new QEvent ( QEvent :: User ) ) ;
73
83
}
74
84
You can’t perform that action at this time.
0 commit comments