←back to thread

115 points saisrirampur | 2 comments | | HN request time: 0s | source
Show context
gsliepen ◴[] No.44568872[source]

  pg_usleep(1000L);
Virtually any time you put a fixed sleep in your program, it's going to be wrong. It is either too long or too short, and even if it is perfect, there is no guarantee your program will actually sleep for exactly the requested amount of time. A condition variable or something similar would be the right thing to use here.

Of course, if this code path really is only taken very infrequently, you can get away with it. But assumptions are not always right, it's better to make the code robust in all cases.

replies(4): >>44569067 #>>44570238 #>>44571006 #>>44571476 #
aspbee555 ◴[] No.44571476[source]
I was working through some ffmpeg timing stuff and the ai kept insisting on putting in sleep functions to try and "solve" it
replies(1): >>44571550 #
1. jeffbee ◴[] No.44571550[source]
Generative coding models are trained on GitHub. GitHub is completely full of inadvisable code. The model thinks this is normal.
replies(1): >>44572350 #
2. nightfly ◴[] No.44572350[source]
Sort of by definition it is normal