Похожие чаты

Hello 👋 How do I check if a channel has

some value?

I don’t want to block the channel. I just want to see if some value is coming in.

If yes then I’ll receive (block) and get it. Otherwise I’ll send a value to it; signalling that some other goroutine is done.

I’ve tried using select for this but I think I’m using it wrong.

Trying two sync two goroutines here. Want to show progress of A if B is done first to indicate that A is still working.

Please advise.

2 ответов

9 просмотров

Channels are for communication data. if an channel is non-empty, this means that nobody worked on the content. For signaling that the sender is done, you can close the channel. Like with maps you can also get an bool from a channel.

You might have the XY problem. If you want to signal that some other goroutine did the work, use an atomic bool and check its value.

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

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

Здравствуйте! Есть вопросы по ПК: 1.1. Безопасно ли запускать программы, которым я не доверяю, в виртуальной машине под KVM+qemu? (x86_64) 1.2. То же самое при использовании ...
Pavel
5
Hi everyone! I have a two-folded message to share today. First: updates and news, as we are being asked for those. We still want to go like we did the last 6 years: we w...
Marten | Unibright.io
31
Я тут пытаюсь переработать архитектуру подсистемы памяти ядра во что-то осмысленное. Есть pmm, который создает набор range’ей(пока что только для ядра, потом для юзерспейса), ...
Evg Resh
9
Комрады, хотел уточнить. Проперть в OnDestroy юнита-хозяина по-прежнему доступна? И еще уточнение: finalization юнита наступает раньше или позже OnDestroy?
Ed Doc
24
У меня вопрос, а какой уровень оптимизации ставить при сборке на i5 4 ядра 16G ddr3 ОЗУ и видюха Geforce GTX 970?
Sir Jiga
18
Guys, what’s the most expensive part of your budget for your business/startup/app/website?
Ice Kream
18
Скажите, можно ли как-то "переместить" динамический массив из одной переменной в другую? Скажем, переместить из TList<> в TArray<>. Именно переместить, а не скопировать. Если ...
Eugene Krasnikov (ᴊɪɴ x)
37
Oh.... Admins at the main TG is already muted me. How many months Sir you muted me? Or forever if you are here @Janevietani @JohnnySonic
Charles Dar
28
Happy Friday and happy CartesiWeekly! This week on the list: 🪲 Bug Buster Update 🎥 Erick de Moura’s interview with Ornella from Web3TV 👽 Thriving Cartesi alien 🇧🇷 SBRC hackat...
Nida | Cartesi - Never DM first or ask for funds!
1
комрады, че-та лыжы не едут var tmpFont: TFont; begin tmpFont:= TFont.Create; try case rgFontColor.ItemIndex of 0: tmpFont.Color:= clWindowText; 1: tmpFo...
Ed Doc
34
Карта сайта