2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

New way for subscribe/notify async about any events.

Two classes base::Observable<Event> and base::Subscriber were added.
base::Observable<Event> can notify about Event-s, while any
base::Subscriber can subscribe and then async receive them.
This commit is contained in:
John Preston
2016-08-18 21:27:43 +02:00
parent 90678d411f
commit ea955635ac
10 changed files with 416 additions and 11 deletions

View File

@@ -275,16 +275,16 @@ public:
SingleDelayedCall(QObject *parent, const char *member) : QObject(parent), _member(member) {
}
void call() {
if (!_pending.loadAcquire()) {
_pending.storeRelease(1);
if (_pending.testAndSetOrdered(0, 1)) {
QMetaObject::invokeMethod(this, "makeDelayedCall", Qt::QueuedConnection);
}
}
private slots:
void makeDelayedCall() {
_pending.storeRelease(0);
QMetaObject::invokeMethod(parent(), _member);
if (_pending.testAndSetOrdered(1, 0)) {
QMetaObject::invokeMethod(parent(), _member);
}
}
private: