Похожие чаты

Hm, do you know what I can use if I

want to send the latest logs of execution from one thread to another?
I want to read in a non-blocking way, and I want not more than latest N lines being on the way at the same time.

What I want to solve, I have a process that I'm running from a thread, I have a UI that shows the last 30 lines, right now I have a Vec that I use as a ring buffer and lock it with a mutex, but I want to make reading it non-blocking.
I could use a channel, but that would mean the process can dump 1000 lines at once, and then the UI thread would need to read all the 1000 lines instead of 30, and all those lines would need to be stored in the memory.

I wonder if something that I want exists

1 ответов

13 просмотров
Pavel- Автор вопроса

So how I solved it: I just use try_lock instead of lock. The UI thread doesn't wait on mutexes now (which makes it always smooth) and it always shows the latest data (it probably can delay showing the data if the thread is starving, but it shouldn't be for really long, and it's lesser evil)

Похожие вопросы

Обсуждают сегодня

А еще в перле можно уже @arr1 + @arr2?
Sergei Zhmylove
53
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
I arrived here after a Chico Crypto show highlighted the project & the Team - the fact that the Team had a long history of successfully working with household names gave me e...
Banter is Bullish
1
Привет всем. появился вопрос. Разрабатываю сайт, в данный момент он запущен. Хостинг beget. Добавляю на сайт яндекс метрику с помощью полей client-settings (взято отсюда http...
Andrew
2
Подскажите, где смотреть результат выполнения программы? Код: ;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, станда...
Егор Анелькин
5
Где в Астане можно купить мясо для шашлыков?
Dancing Іңұқәһүғө
21
Lers say somehow tor got shut down What then?
Mark Keller
16
Добрый день подскажите пожалуйста может кто то сталкивался с ошибками Sentry 22.10.0 развернутым из helm чарт в Kubernetes? Изначально 3 дня назад очень стало много событий ух...
Tire4 Finist Devops
1
Ну чё, сегодня все в гавно?))
ᅠ🚀
20
;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, стандартный ;вызов процедуры ;option casemap:no...
Егор Анелькин
1
Карта сайта