[plt-scheme] embedding: scheme_check_threads question

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Apr 24 10:38:37 EDT 2009

At Fri, 24 Apr 2009 15:28:51 +0100, Dave Griffiths wrote:
> I've yet to time things accurately, but I replaced the
> scheme_check_threads loop with usleep(1000), and I get problems again.
> Adding (sleep 0.01) to the end of my scheme update loop works well
> though (which I guess effectively does the same thing as calling
> scheme_check_threads).

For what it's worth (still guessing a lot about the program):

`(sleep 0.01)' similar to calling scheme_check_threads() in a loop for
0.01 seconds. The difference is that `(sleep 0.01)' will not bother
spinning if an immediate scheme_check_threads() wouldn't do anything
(e.g., because there has been no socket activity).

If the threads communicate, then that's significantly different than
usleep(1000) and then calling scheme_check_threads() once. The `(sleep
0.01)' approach lets threads react to socket events and trigger
immediate execution in other threads, while the usleep(1000) followed
by scheme_check_threads() won't allow much of that.

Posted on the users mailing list.