bump thread priority in encoded payload generation to fix thread starvation issues

git-svn-id: file:///home/svn/framework3/trunk@3777 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2006-07-30 18:45:36 +00:00
parent f8ff8c6d7b
commit 144249b34d
1 changed files with 24 additions and 10 deletions

View File

@ -46,6 +46,16 @@ class EncodedPayload
self.encoder = nil self.encoder = nil
self.nop = nil self.nop = nil
# Increase thread priority as necessary. This is done
# to ensure that the encoding and sled generation get
# enough time slices from the ruby thread scheduler.
priority = Thread.current.priority
if (priority == 0)
Thread.current.priority = 1
end
begin
# First, validate # First, validate
pinst.validate() pinst.validate()
@ -60,6 +70,10 @@ class EncodedPayload
# Finally, set the complete payload definition # Finally, set the complete payload definition
self.encoded = (self.nop_sled || '') + self.encoded self.encoded = (self.nop_sled || '') + self.encoded
ensure
# Restore the thread priority
Thread.current.priority = priority
end
# Return the complete payload # Return the complete payload
return encoded return encoded