mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2026-07-17 16:36:49 +00:00
VNC-151 Use arena
This commit is contained in:
parent
2f78558fea
commit
b6eb3b703e
2 changed files with 17 additions and 12 deletions
|
|
@ -38,6 +38,7 @@ namespace rfb {
|
|||
base_video_encoder(encoder),
|
||||
available_encoders(encoders) {
|
||||
screens_to_refresh.reserve(T);
|
||||
arena.initialize(MAX_SCREENS);
|
||||
}
|
||||
|
||||
template<uint8_t T>
|
||||
|
|
@ -219,16 +220,20 @@ namespace rfb {
|
|||
if (screens_to_refresh.size() > 1) {
|
||||
tbb::task_group_context ctx;
|
||||
|
||||
tbb::parallel_for_each(screens_to_refresh.begin(), screens_to_refresh.end(), [this, pb, &ctx, forceKeyFrame](uint8_t index) {
|
||||
if (ctx.is_group_execution_cancelled())
|
||||
return;
|
||||
arena.execute([&] {
|
||||
tbb::parallel_for_each(screens_to_refresh.begin(),
|
||||
screens_to_refresh.end(),
|
||||
[this, pb, &ctx, forceKeyFrame](uint8_t index) {
|
||||
if (ctx.is_group_execution_cancelled())
|
||||
return;
|
||||
|
||||
auto &screen = screens[index];
|
||||
if (auto *encoder = screen.encoder; encoder) {
|
||||
screen.dirty = encoder->render(pb, forceKeyFrame);
|
||||
if (!screen.dirty)
|
||||
ctx.cancel_group_execution();
|
||||
}
|
||||
auto &screen = screens[index];
|
||||
if (auto *encoder = screen.encoder; encoder) {
|
||||
screen.dirty = encoder->render(pb, forceKeyFrame);
|
||||
if (!screen.dirty)
|
||||
ctx.cancel_group_execution();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (ctx.is_group_execution_cancelled())
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@
|
|||
* USA.
|
||||
*/
|
||||
#pragma once
|
||||
#include <tbb/spin_mutex.h>
|
||||
#include <tbb/task_arena.h>
|
||||
#include <vector>
|
||||
#include "KasmVideoConstants.h"
|
||||
#include "VideoEncoder.h"
|
||||
#include "rfb/Encoder.h"
|
||||
#include "rfb/ffmpeg.h"
|
||||
|
||||
inline constexpr uint8_t MAX_SCREENS = 8;
|
||||
inline constexpr uint8_t MAX_SCREENS = 4;
|
||||
|
||||
namespace rfb {
|
||||
template<uint8_t T = MAX_SCREENS>
|
||||
|
|
@ -41,9 +41,9 @@ namespace rfb {
|
|||
|
||||
uint64_t mask{};
|
||||
std::vector<uint8_t> screens_to_refresh;
|
||||
tbb::spin_mutex conn_mutex;
|
||||
|
||||
std::array<screen_t, T> screens{};
|
||||
tbb::task_arena arena;
|
||||
const FFmpeg &ffmpeg;
|
||||
VideoEncoderParams current_params;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue