Map keys read and reWrite sync is not working for socket programming

Thanks Nathan, then you mean that only call to map key values if a read or write a key map, rigth, if i need to compare it use other fuction thant not put more delay to my map key read or write, rigth?
thaks for all guys, I’ll apreciated a lot your help…new folower of Go from Chile!!!

1 Like

Right.

Build methods for PidCCerr for the common behaviors you have. For a comparison, you could get both values with a single lock, for example.

Hello Guys, Nathan, Chris, and Jakob… now is working as much better that after…great news…
and also with your help, obviously, I found two bugs problem.
1- problems with lock and unlock maps was wrong implemented.
2-goroutine generate a problem because access to map keys at the same time (Thread problem) because is sniffer and the packs are incoming very faster and need to do as sequential.

I’ll still need test it because I’ve tested for a few minutes …
thanks again and I’ve appreciated a lot
also the latest question…if I need to replace a map key, for example:

m[k1] := 1

need to replace for this
m[k1] := 2

if the same do it ?..
m[k1] := 1
m[k1] := 2

or is better do it?
m[k1] := 1
delete(m,k1)
m[k1] := 2

thanks again !!!

Setting m[k1] to a new value will replace the old value (just like any other variable assignment). So, Do this:

m[k1] = 2

I do not see why a delete() would be necessary here, but maybe I just lack the context. Do you have a specific use case in mind where only updating the element (instead of deleting and re-creating it) would break something?

Thanks Nathan!!!, I’ll do it

Hello Chris…no is just only for follow the rules…If delete exists as option i think that should be used, but it could generate a problem as you told me…thanks, Chris!! for your support.

Hello guys…now all was working as I expect, but is just only working for low bitrate , not more that 5 Mbps , I saw some post that for socket programming , and some developer recommend “DPDK”, I’ll looking for more information about that…
thanks guys for all!!!

1 Like

Glad to hear its working now.

Go has some good tools to help improve your code’s performance. My tutorial, Concurrency Slower?, introduces them by way of an example.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.