guardia-messenger/node_modules/react-native/ReactCommon/react/runtime/BufferedRuntimeExecutor.cpp
DESKTOP-TKLFCPRython f29f525c77 refactor: 101.79.17.164 → zioinfo.co.kr 전체 도메인 변환 + Manager UI 배포
- 37개 파일 IP → zioinfo.co.kr 치환 (소스/매뉴얼/설정/하네스)
- Manager DrConsole/NetworkConsole/CsapConsole 빌드 + /var/www/manager/ 배포
- 테스트: Manager HTTP 200, ITSM 신규 API 7개 전체 200

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 10:09:17 +09:00

61 lines
1.6 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "BufferedRuntimeExecutor.h"
#include <cxxreact/MessageQueueThread.h>
#include <algorithm>
namespace facebook::react {
BufferedRuntimeExecutor::BufferedRuntimeExecutor(
RuntimeExecutor runtimeExecutor)
: runtimeExecutor_(runtimeExecutor),
isBufferingEnabled_(true),
lastIndex_(0) {}
void BufferedRuntimeExecutor::execute(Work&& callback) {
if (!isBufferingEnabled_) {
// Fast path: Schedule directly to RuntimeExecutor, without locking
runtimeExecutor_(std::move(callback));
return;
}
/**
* Note: std::mutex doesn't have a FIFO ordering.
* To preserve the order of the buffered work, use a priority queue and
* track the last known work index.
*/
uint64_t newIndex = lastIndex_++;
std::scoped_lock guard(lock_);
if (isBufferingEnabled_) {
queue_.push({.index_ = newIndex, .work_ = std::move(callback)});
return;
}
// Force flush the queue to maintain the execution order.
unsafeFlush();
runtimeExecutor_(std::move(callback));
}
void BufferedRuntimeExecutor::flush() {
std::scoped_lock guard(lock_);
unsafeFlush();
isBufferingEnabled_ = false;
}
void BufferedRuntimeExecutor::unsafeFlush() {
while (queue_.size() > 0) {
const BufferedWork& bufferedWork = queue_.top();
Work work = std::move(bufferedWork.work_);
runtimeExecutor_(std::move(work));
queue_.pop();
}
}
} // namespace facebook::react