Похожие чаты

Anyone used github.com/orcaman/concurrent-map? Is is it a good package?

20 ответов

27 просмотров

https://github.com/orcaman/concurrent-map/blob/master/concurrent_map.go#L17 no way, they embedded a mutex, what the...

ㅤ- Автор вопроса
Roman Sharkov
https://github.com/orcaman/concurrent-map/blob/mas...

I always embed mutex in my needed structs, is that a bad practice?


I always embed mutex in my needed structs, is that...

what’s the reason to expose Lock() and Unlock() to your API?!

ㅤ- Автор вопроса
Roman Sharkov
what’s the reason to expose Lock() and Unlock() to...

oh, no I don't expose it. but I embed mutex like: type JoeBidenIsNotPresident { sync.Mutex val int } func(JBINP ...) Add() { JBINP.Lock() JBINP.val++ JBINP.Unlock() } ohhh, I guess this exposes mutex as well?


oh, no I don't expose it. but I embed mutex like: ...

you do expose it, that’s what embedding does


oh, no I don't expose it. but I embed mutex like: ...

also, use defer Unlock(), there’s no more additional runtime cost for those kinds of defers since 1.14

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

What about sync.Map? What’s missing there for you?

ㅤ- Автор вопроса
Mark X
What about sync.Map? What’s missing there for you?

I don't know lol, actually I haven't really studied all aspects of mutexes. Let me see that


I don't know lol, actually I haven't really studie...

just use sync.Map if you don’t know why you’d need something else

ㅤ- Автор вопроса
Roman Sharkov
just use sync.Map if you don’t know why you’d need...

I'm using it to control conversations so functions in the app don't call db independently and use an interface to interact with conversations table

ㅤ- Автор вопроса
Roman Sharkov
I don’t understand 🙂

Conversation table in db has a few fields like last_message_Id. If 2 users in a conversation call that record at the same time and increment last_message_id, then both might get same message ids.


Conversation table in db has a few fields like las...

you’re supposed to use transactions for these kinds of problems

ㅤ- Автор вопроса
Roman Sharkov
you’re supposed to use transactions for these kind...

I'm not sure if transactions would help here. last_message_id = 0 User A sends a new message to User B User B sends a new message to User A Both at the same time, now the updates handler goroutine fetch last_message_id for each request, both will fetch 0 in this case. So if they try to update the value, it will be 1 instead of 2. I thought transactions is only when you want to write data


I'm not sure if transactions would help here. la...

that’s exactly what transactions were made for


I'm not sure if transactions would help here. la...

> I thought transactions is only when you want to write data no.

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

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
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
Карта сайта