Похожие чаты

I am reading: https://www.jtolio.com/2016/03/go-channels-are-bad-and-you-should-feel-bad/ and I can't really understand it. In

the first example, why does the mutex solve the issue?

2 ответов

13 просмотров

mutexes are about synchronization. channels are about communication.

When you program concurrently the variables are exposed being shared and that is where the channel comes in to ensure communication in a safe way in a competitive scenario. In Go it is possible to use the synchronization primitives and this is very interesting because he did not eliminate this possibility, the language allows its use, in the past we did not have Maps to work in a competing environment, for this to be possible we had to implement and see just how could we do this? Using Mutex ... This is an implementation that I did in the past https://gist.github.com/jeffotoni/13160dcac45068f31d56193cd0cbbe49 and just below in the answer another solution using sync.Map. The examples in the post depict to take care and reflect more on primitives using Mutex and Channel, and that in some scenarios it is interesting to use primitives instead of channel, super valid from his point of view, he needed to lower the level even more in his projects . It will arrive at a moment that will come up against GC do Go in the memory heaps and then the conversation starts to get even more interesting. Remembering that Go is a new lang, which is maturing and advancing very fast, it has several points that need to improve as in any other lang. Now, like Go community, I'm sure there are few like ours... 🥳🥳🥳🥳 but But we know that the use of sync.Mutex when we have thousands of goroutines the performance is affected, making a very simple benchmarking to understand but read this post https://stackoverflow.com/questions/57562606/why-does-sync-mutex-largely-drop-performance-when-goroutine-contention-is-more-t

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

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

Hey everyone! I won’t focus too much on what this person said (it’s clear they don’t understand the scope of what TF and TELOSX are achieving), but I’ll put it simply for thos...
Ana Ojeda
2
как правильно удалить сддм? прописал в etc/portage.use/plasma-meta -sddm , но при обновлении юзов мне предлагает поставить lightdm (ещё лучше 😡), добавил туда - display-manage...
REDis
25
Telos is at a pivotal moment. While ambitious projects like zkEVM and SNARKtor have shown promise, the delay in delivering EVM 2.0—a cornerstone of the ecosystem—is a growing ...
Trinidad
8
Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
#include <stdio.h> #include <stdlib.h> #include <time.h> void mass_first_generate(int mass[5][7]) {     for (int N = 0; N < 5; N++) {         for (int A = 0; A < 7; A++) {   ...
Чувак
6
Всем привет! Решаю 99 OCaml Problems и столкнулся со следующей проблемой (прошу палками не забивать, я OCaml практически не трогал до этого момента): open OUnit2 let create_...
К|/|pи/\/\ 6е3yглbIи
2
Except the wealthiest, people that buy crypto want to "cash out" at the end of the day, one way or another. Converting to fiat is craziness, converting to BTC is unwise. Hold ...
Erdelanax
2
Hello guys, hope you can help me with a quick question. I've staked some ZIL using Atomic Wallet some while ago and wanted to claim my rewards and unstake it. Atomic Wallet sa...
Martin | #bornbrave
14
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
https://www.linkedin.com/posts/ugama-benedicta-kelechi-codergirl-103041300_mobiledevelopment-fluttertraining-handsonlearning-activity-7263445699227254784-IdHB?utm_source=share...
CoderGirl
16
Карта сайта