Created
June 7, 2012 15:10
-
-
Save garrettwilkin/2889315 to your computer and use it in GitHub Desktop.
Attempting Non-blocking IO with TCL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Non-blocking channel | |
set nb "data.txt" | |
set data [open $nb r] | |
fconfigure $data -blocking 0 | |
puts "$nb [fconfigure $data]" | |
#Blocking channel | |
set bl "data2.txt" | |
set data2 [open $bl r] | |
puts "$bl [fconfigure $data2]" | |
#Stdout non-blocking... does this really work? | |
puts "stdout [fconfigure stdout]" | |
fconfigure stdout -blocking 0 | |
puts "stdout [fconfigure stdout]" | |
#Time Check. | |
set then [clock clicks ] | |
set e [expr [clock clicks ] - $then] | |
puts "$then $e" | |
puts "Reading Non-blocking channel $nb" | |
set d [read $data [file size $nb]] | |
#Time Check. | |
set now [clock clicks ] | |
set e [expr $now - $then] | |
puts "$now $e" | |
puts "Reading Blocking channel $bl" | |
set d2 [read $data [file size $bl]] | |
#Time Check. | |
set now [clock clicks ] | |
set e [expr $now - $then] | |
puts "$now $e" | |
puts "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment