On 4/11/08, felix winkelmann <[EMAIL PROTECTED]> wrote: > On Sat, Apr 5, 2008 at 8:10 PM, Jim Ursetto <[EMAIL PROTECTED]> wrote: > Uh oh... This is a case that should probably be avoided. I couldn't even > say what exactly happens, but you will have to do some locking because > the Scheme thread-context will be different when you return from the > callback (as you have described above). When you say "thread 2 enters > the callback" does that mean that a context switch occurs while the > callback is executing?
Yes. OK, that's what I thought. I changed my approach completely (doesn't use callbacks anymore) -- so everything is ok. But I did realize in the meantime that this could affect any multithreaded program using callbacks, as if a context switch occurs during a callback then callback returns may occur out of order. (It could occur if one thread registered a GUI callback and one registered a database callback--unless you somehow prevent context switches within callbacks or arrange it externally so callbacks may never overlap). For example, I think it is unsafe to use sqlite3:define-function or sqlite3:define-collation if you have multiple threads, even using different database connections, as the callbacks may overlap in time. _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
