forked from rsocket/rsocket-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScheduledSubscription.cpp
More file actions
37 lines (30 loc) · 869 Bytes
/
ScheduledSubscription.cpp
File metadata and controls
37 lines (30 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2004-present Facebook. All Rights Reserved.
#include "rsocket/internal/ScheduledSubscription.h"
#include <folly/io/async/EventBase.h>
namespace rsocket {
ScheduledSubscription::ScheduledSubscription(
yarpl::Reference<yarpl::flowable::Subscription> inner,
folly::EventBase& eventBase) : inner_(std::move(inner)),
eventBase_(eventBase) {
}
void ScheduledSubscription::request(int64_t n) noexcept {
if (eventBase_.isInEventBaseThread()) {
inner_->request(n);
} else {
eventBase_.runInEventBaseThread([inner = inner_, n]
{
inner->request(n);
});
}
}
void ScheduledSubscription::cancel() noexcept {
if (eventBase_.isInEventBaseThread()) {
inner_->cancel();
} else {
eventBase_.runInEventBaseThread([inner = inner_]
{
inner->cancel();
});
}
}
} // rsocket