Thread: 2^1466L done
View Single Post
Old 2006-03-01, 00:49   #6
Wacky's Avatar
Jun 2003
The Texas Hill Country

32·112 Posts

Originally Posted by Jushi
How about programming the nfsnetclient to immediatly stop sieving when the user asks to, losing the current line? This way sieving one line could take several minutes, but the program will still stop immediately.

I have to admit I don't know the internals of the code, but I'm sure this is not hard to implement.
It is more difficult than you think. Because of I/O buffering and "GUI" event loops, you cannot simply "abort" a running thread. In most (OS) cases, you end up having to "poll" to determine if the program should stop. The cost of polling is not insignificant. Therefore, you do not want do do it too often. Finding an appropriate location within the nested loops my not be easy to do.
If it is too low, not only do you waste the time polling, but you may also invalidate the caches, adding even more overhead. On the other hand, if the polling is done too far out, it may not be frequent enough to give satisfactory response. Considering that the length of a "line" may vary by a couple orders of magnitude, finding the right balance is not trivial.
Wacky is offline