New answers tagged

2

One thing that sticks out as highly suspect is this loop: while (1) { srand(time(NULL)); int n = (int)ceil(rand()) % 22; sleep(1); You're re-seeding on every iteration, which means that any random state from the previous iteration is obliterated. Given the context - this is in a test method - you probably just want to srand() ...


3

Don't start names with an underscore The C language reserves some identifiers starting with one or two underscores. While your code may work, it is best to avoid it. It's also more common to write this: typedef struct BoundedBuffer BoundedBuffer_t; So the struct's name has no prefix or postfix, the typedef'ed name has _t appended to it. However, the _t ...


1

"Actually you code is pretty much this. Simple and boring as most other good Go code" I thought. At this point I could say "Wrap your c <- true with a select statement, add the third case <-ctx.Done: to handle possible deadlock and you are ready to go". But. Does it really should be this way? Yep, this works and does the job, but ...


Top 50 recent answers are included