Похожие чаты

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

19 просмотров

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

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

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

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
Добрый вечер. Есть вопрос, а может и предложение. Был у меня диалог в другой группе о делфи и я задался вопросом: "А нельзя ли в делфи цвет //коментария и {комментария} сде...
Kraszx
24
How about the project bro Likes the community not that active ?
🅿️abby_FX
19
Всем привет! Подскажи, пожалуйста, как передать в TComboBox сразу значение и id записи. На Delphi я делал так: ComboBox1.Items.AddObject('Какое-то значение', Pointer(id запис...
Евгений
13
Мдя, прикол, боевая сборка запускается (именно под отладчиком) после F9 примерно полторы минуты (97 секунд если быть точным). Начал копать - проблема детектится сразу - зависа...
Александр (Rouse_) Багель
38
How are we going bro about the Raids ??
🅿️abby_FX
13
Россия стала ввозить сливочное масло из ОАЭ. Просто ради любопытства взглянул на статистику и впечатлился. У арабов среднестатистическая корова дает около 42 литров молока в д...
Foxcool
2
Здравствуйте, вопрос по структурам данных. Были у вас случаи, когда пришлось писать деревья или двунаправленные списки?
/ /
50
Товарищи, кто работа с iphelper? Или может я в самой логике ошибки фигачу, не пойму.... var ifTable : PMIB_IFTABLE; size, corSize: DWORD; Buffer ...
Warfarellen
4
я так понимаю, я так подозреваю, что создание такого плагина для человека, кто умеет писать плагины для делфи потребует минут 5-10 времени. но это мое подозрение. хотелось бы ...
Kraszx
7
Карта сайта