Add non-template Scheduler::destroy_on_scheduler_impl.
This commit is contained in:
parent
0f87447ffc
commit
51513f1780
@ -153,6 +153,8 @@ class Scheduler {
|
|||||||
private:
|
private:
|
||||||
static void set_scheduler(Scheduler *scheduler);
|
static void set_scheduler(Scheduler *scheduler);
|
||||||
|
|
||||||
|
void destroy_on_scheduler_impl(int32 sched_id, Promise<Unit> action);
|
||||||
|
|
||||||
class ServiceActor final : public Actor {
|
class ServiceActor final : public Actor {
|
||||||
public:
|
public:
|
||||||
void set_queue(std::shared_ptr<MpscPollableQueue<EventFull>> queues);
|
void set_queue(std::shared_ptr<MpscPollableQueue<EventFull>> queues);
|
||||||
|
@ -362,6 +362,21 @@ void Scheduler::run_on_scheduler(int32 sched_id, Promise<Unit> action) {
|
|||||||
action.set_value(Unit());
|
action.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scheduler::destroy_on_scheduler_impl(int32 sched_id, Promise<Unit> action) {
|
||||||
|
auto empty_context = std::make_shared<ActorContext>();
|
||||||
|
empty_context->this_ptr_ = empty_context;
|
||||||
|
ActorContext *current_context = context_;
|
||||||
|
context_ = empty_context.get();
|
||||||
|
|
||||||
|
const char *current_tag = LOG_TAG;
|
||||||
|
LOG_TAG = nullptr;
|
||||||
|
|
||||||
|
run_on_scheduler(sched_id, std::move(action));
|
||||||
|
|
||||||
|
context_ = current_context;
|
||||||
|
LOG_TAG = current_tag;
|
||||||
|
}
|
||||||
|
|
||||||
void Scheduler::add_to_mailbox(ActorInfo *actor_info, Event &&event) {
|
void Scheduler::add_to_mailbox(ActorInfo *actor_info, Event &&event) {
|
||||||
if (!actor_info->is_running()) {
|
if (!actor_info->is_running()) {
|
||||||
auto node = actor_info->get_list_node();
|
auto node = actor_info->get_list_node();
|
||||||
|
@ -172,24 +172,11 @@ inline void Scheduler::send_to_scheduler(int32 sched_id, const ActorId<Actor> &a
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void Scheduler::destroy_on_scheduler(int32 sched_id, T &value) {
|
inline void Scheduler::destroy_on_scheduler(int32 sched_id, T &value) {
|
||||||
if (sched_id < 0 || sched_id_ == sched_id || value.empty()) {
|
if (!value.empty()) {
|
||||||
return;
|
destroy_on_scheduler_impl(sched_id, PromiseCreator::lambda([value = std::move(value)](Unit) {
|
||||||
}
|
|
||||||
|
|
||||||
auto empty_context = std::make_shared<ActorContext>();
|
|
||||||
empty_context->this_ptr_ = empty_context;
|
|
||||||
ActorContext *current_context = context_;
|
|
||||||
context_ = empty_context.get();
|
|
||||||
|
|
||||||
const char *current_tag = LOG_TAG;
|
|
||||||
LOG_TAG = nullptr;
|
|
||||||
|
|
||||||
run_on_scheduler(sched_id, PromiseCreator::lambda([value = std::move(value)](Unit) {
|
|
||||||
// destroy value
|
// destroy value
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
context_ = current_context;
|
|
||||||
LOG_TAG = current_tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Scheduler::before_tail_send(const ActorId<> &actor_id) {
|
inline void Scheduler::before_tail_send(const ActorId<> &actor_id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user