Похожие чаты

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

21 просмотр

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- Автор вопроса

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта