Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Attempting Non-blocking IO with TCL
#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
You can’t perform that action at this time.