Похожие чаты

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 ответов

7 просмотров

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

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

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

А чем вам питонисты не угодили?😂
.
79
Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
or any website to buy prepaid card with xmr that's not trocador that's down?
Umbrella Party Partner
18
Hi, I can't understand promises in JavaScript and what we should use them for (maybe the teacher didn't teach well XD). Do you have a solution for this? And are promises used...
A
29
Добрый день, LO Writer, проблема с нумерацией таблиц (вставка названия). У меня два стиля нумерованных списка, один для основного текста (вида 1.1.1) другой доя приложений (ви...
Виктор
6
Ещё такой вопрос. Мне необходимо хранить пароль пользователя локально. Для этого планирую использовать ini файл. Это для автозаполнения полей логин и пароль при авторизации. Е...
Евгений
19
всем доброго времени суток! имею вопрос: как понять ТОЧНО, что на нексус производится атака или он перегружен? исходные данные: - Nexus OSS 3.67.1-01 на OrientDB - Total co...
Michael Kostelcev
11
Xem delist ho rha hai agr naa bhechu toh kya hoga after 1 july?
ABHI
27
Ты просто гитлеровскую эстетику плохо понимаешь. Он же всё под Цезаря делал. А это как бы запрещённый приём в политике. Пиджаки они зачем все носят? Чтобы показать что они тип...
Ivan Kropotkin
4
Did you guys see the latest tweet from TonGifts? 🚀
Mike
44
Карта сайта