Overview
| Artifact ID: | 5c5896b427bcc9bfe4f575299b24c96a37214dad |
|---|---|
| Ticket: | 1960647fffffffffffffffffffffffffffffffff
Add ability to use poll() in TclUnixWaitForFile() |
| User & Date: | das on 2008-06-15 18:21:28 |
Changes
- icomment:
Logged In: YES user_id=90580 Originator: NO IMO the fact that TclUnixWaitForFile() and Tcl_Sleep() call select() directly is fundamentally wrong anyway, they should be using the same mechanism as the notifier to suspend, i.e. in the threaded case the notifier thread should be doing the select for TclUnixWaitForFile(), same as waiting/polling from Tcl_WaitForEvent(). Calling select() directly prevents being woken up from another thread (except through a signal), which e.g. prevents being canceled via TIP285 during a waitforfile or sleep. Moreover, as I discovered in my current reworking of the Mac OS X CoreFoundation notifier to add support for embedding, the notifier not being used in TclUnixWaitForFile() and Tcl_Sleep() forces an alternative event loop to #ifdef out the standard unix versions of these and replace them (in my case with versions based on CFRunLoop to ensure the embedding event loop keeps processing events during waitforfile/sleep). If an embedder wants to replace the notifier via Tcl_SetNotifier() this workaround is not possible, and as TclUnixWaitForFile()/Tcl_Sleep() are not hookable, they will very likely be a big problem for any custom event loop (such as the Xt notifier)... This would all go away if the low-level waiting action in the notifier were factored out (i.e. signaling the notifier thread and waiting on the condition variable resp. calling select() in the single-threaded case), TclUnixWaitForFile() and Tcl_Sleep() could then call this new low-level wait instead of select() directly. I intend to work on doing exactly this in the next few weeks, as part of my look at the unix notifier to delay notifier thread creation until needed, so no need to waste further cycles looking at this patch, it attacks the wrong problem IMO.
- login: "das"
- mimetype: "text/plain"
- username: "das"