Похожие чаты

If we have this code : for {

go func() {
log.Println("something")
}()
}

can we understand that goroutine in previous loop step done its job ??
in other words can we synchronize these goroutines that are in a loop ??

12 ответов

6 просмотров

no. This code will ultimately crash your system. You'll run out of memory fast

what do you mean by synchronize? Make them be called serially? If so, then why do you need those goroutines in the first place?

Masoud- Автор вопроса
Roman Sharkov
no. This code will ultimately crash your system. Y...

not this code exactly , imagine the loop is finite

Masoud- Автор вопроса
Roman Sharkov
what do you mean by synchronize? Make them be call...

yeah serially , my project is a webrtc sfu and in a loop I will send rtp packets to clients and after that I will write them to a file in disk but this i/o task is time consuming , I don't want that sending rtp packets directly to clients have lags and delay because of this I want to this saving to disk task be run on other goroutine(s)

Masoud
yeah serially , my project is a webrtc sfu and in ...

is a goroutine pool what you're looking for? or do you want to execute N simultaneous tasks and wait for all of them to finish?

Masoud- Автор вопроса
Roman Sharkov
is a goroutine pool what you're looking for? or do...

emm...I don't know exactly I don't think goroutine pool help me and sync.waitGroup also wont help me

Masoud
emm...I don't know exactly I don't think goroutine...

I still don't understand your problem. Why do you want goroutines to execute serially one after another? Can't you just do that in 1 goroutine?

Masoud
yeah serially , my project is a webrtc sfu and in ...

so you have N connections you want to write 1 packet to each of the N connections and resume once all of them are written, right?

Masoud- Автор вопроса
Roman Sharkov
I still don't understand your problem. Why do you ...

I think saving incoming video packets (parts) in disk should be serially right ?? :)

Masoud- Автор вопроса
Roman Sharkov
so you have N connections you want to write 1 pack...

no not resume , first part of what you said is right but this part is not the problem in that loop that I said after I sent for example packet X to clients then I will append that to recording file but this task is time consuming (assume that we don't have nvme disk :) )

Masoud
no not resume , first part of what you said is rig...

var packet []byte for _, c := range connections { c.Send(packet) } file.Write(packet) is this your business logic (simplified)?

Masoud- Автор вопроса

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

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

Anyone here suffers from unexplained aural migraines, who would be up for talking for a bit? Doesn't *have* to be aural, but I am not asking about headaches, I mean actual mi...
Martin Rys
55
We heading to 1.1$ 🤔?
CryptoBo$$
35
Ideally, when we launch a game from a particular studio, that studio should have the right to access the uniqs from their game on our wallet. For example, if you die in a Ubis...
Lisandru
16
A couple thoughts from a random internet stranger: 1. If you want this project to gain traction you cannot keep being negative. If I just came here after finding out about Kd...
Eric Wild
46
Who understand exactly the uniqd in game ? Does it mean that transactions are auto signed inside the game without interruption? If yes , then how can ultra retrieve elements...
Zaa
15
i justHey. Im holding kadena almost 3 years now. Its my only investment what isn't in profit. But i thought for years that its just need some more time but i haven't seen that...
Riki
7
Всем здравствуйте!) У меня такой вопрос. Есть два роута, роут1 и роут2. Они связаны с очередью some_queue. По задаче предполагается, что есть два паблиша. Паблиш1 отправляет...
Format
10
Сonst magicTgHTML = (text, entities) => { let processedText = text; let offsetShift = 0; entities.forEach(entity => { const { offset, length, type, url, ...
Андрей
1
So, did you guys catch the latest AMA with David from FunToken?
Noah Noure
15
Вопрос по WIN32: Насколько я понимаю то все функции win32 привязаны к объектам операционной системы. Например консоль, файл, кисть, окна итд. Следовательно функции win32 упра...
Tommy Vercetti
6
Карта сайта