Skip to main content

All Questions

Tagged with
-3 votes
1 answer
30 views

FanIn pattern blocks when trying to send and receive simultaneously [duplicate]

package main import ( "fmt" ) func main() { even := make(chan int) odd := make(chan int) quit := make(chan int) fanin := make(chan int) go send(even, odd, quit) ...
Блабла Блаблов's user avatar
0 votes
2 answers
51 views

Different Behaviors in Go Race Condition Scenarios

I'm trying to understand why two similar pieces of code behave differently. Both snippets create a large number of goroutines that try to append to the same slice concurrently, which I understand is a ...
Husin Wijaya's user avatar
  • 1,447
0 votes
1 answer
74 views

Two golang goroutines sending messages to the same channel result in a 10-fold increase in time consumption?

Why is there such a significant difference in the time taken for sending and receiving data through a channel between two goroutines? golang version 1.18 this is my code package main import ( &...
cheng xu's user avatar
-1 votes
2 answers
82 views

What problems might arise from ignoring this race condition?

I wish to represent a service that receives triggers to run a particular task, however it only runs that task once at a given time while ignoring concurrent triggers. My brain came up with an ...
shampu's user avatar
  • 51
2 votes
0 answers
42 views

concurrent kafka client offset commit management data structure [closed]

Question: Comparing Ring Buffer with Hash Map and Interval Designs for Kafka Client - Which is Better? I'm working on optimizing a Kafka client for high-throughput message processing. We're ...
Jack Peng's user avatar
  • 610
0 votes
1 answer
44 views

Go channel sometimes not receiving the last value

I'm currently learning go channels, and I'm trying out this piece of code. It creates 10 goroutines which sends a 1000 1s each to a channel. Then another go routine receives it and adds it to a ...
razzz's user avatar
  • 13
0 votes
0 answers
68 views

Request Chunks from the peer in parallel in golang over a tcp connection

I'm building a P2P file transfer system in Go that fetches chunks of data from peers in parallel. While sequential requests work fine, parallel requests using goroutines behave inconsistently, ...
Tarun Kavipurapu's user avatar
0 votes
1 answer
171 views

Performance in Go: Mutex vs RWMutex

There are two types of mutex in Go: Mutex and RWMutex Mutex offers func Lock() and func Unlock(). RWMutex offers those functions plus func RLock() and func RUnlock(). From what I understand, we ...
tbmsilva's user avatar
  • 467
-1 votes
1 answer
53 views

GO Cond - fmt.Println after wg.Done ended up dead lock

Unable to understand this dead lock situation in golang, i have below to go code with pub and sub pattern package main import ( "fmt" "sync" ) func main() { cond := ...
Hari's user avatar
  • 1,613
1 vote
1 answer
36 views

How to implement ordered fan-in (proper message passing for my language)?

I'm the creator of https://github.com/nevalang/neva It's a dataflow programming where you have nodes that do message passing through ports. I use go channels to implement that. However, I faced an ...
emil14's user avatar
  • 81
-1 votes
1 answer
66 views

Is sync.Map LoadOrStore subject to race conditions?

I'm using sync.Map's LoadOrStore method in Go. I'm trying to understand if there could be a race condition leading to multiple evaluations of the value creation function. I'm trying to understand if ...
Zanko's user avatar
  • 4,594
1 vote
1 answer
130 views

Goroutine inside function

I've read https://go.dev/blog/pipelines and there're two functions: // move numbers into a channel func gen(nums ...int) <-chan int { out := make(chan int) go func() { for _, n := ...
iwa2no's user avatar
  • 23
0 votes
0 answers
64 views

How many go routines will be created at runtime?

In an interview today, I got a problem to write a program with 2 goroutines to generate even and odd sequence and synchronize them to print the sequence of number. Later, I was asked how many routines ...
Eshant Gupta's user avatar
1 vote
1 answer
45 views

How to timeout concurrent calls when iterating through a list of items

I was looking into a problem where I need to process a bunch of items in a list. Now I need only the results from the items which can be processed in the configured time, and other results need to be ...
sudeepgupta90's user avatar
1 vote
1 answer
74 views

Accessing a shared map in go concurrently

I'm new at concurrency and I'm facing the following problem. I have an external for loop, for getting rows from the database. I want in every single loop to fill the vertexDistribution map for year := ...
Nepiosxaris's user avatar

15 30 50 per page
1
2 3 4 5
93