/head: changeset 99

Updated.
This commit is contained in:
jgoerzen 2002-07-11 10:14:29 +01:00
parent 36cc6105e5
commit 3e6b420c58

View File

@ -113,6 +113,8 @@ class TkUI(UIBase):
self.verbose = verbose self.verbose = verbose
self.top = Tk() self.top = Tk()
self.threadframes = {} self.threadframes = {}
self.availablethreadframes = []
self.tflock = Lock()
t = threadutil.ExitNotifyThread(target = self.top.mainloop, t = threadutil.ExitNotifyThread(target = self.top.mainloop,
name = "Tk Mainloop") name = "Tk Mainloop")
@ -126,11 +128,18 @@ class TkUI(UIBase):
def gettf(s): def gettf(s):
threadid = thread.get_ident() threadid = thread.get_ident()
s.tflock.acquire()
try:
if threadid in s.threadframes: if threadid in s.threadframes:
return s.threadframes[threadid] return s.threadframes[threadid]
if len(s.availablethreadframes):
tf = s.availablethreadframes.pop(0)
else:
tf = ThreadFrame(s.top) tf = ThreadFrame(s.top)
s.threadframes[threadid] = tf s.threadframes[threadid] = tf
return tf return tf
finally:
s.tflock.release()
def _msg(s, msg): def _msg(s, msg):
s.gettf().setmessage(msg) s.gettf().setmessage(msg)
@ -138,11 +147,15 @@ class TkUI(UIBase):
def threadExited(s, thread): def threadExited(s, thread):
threadid = thread.threadid threadid = thread.threadid
print "Thread %d exited" % threadid print "Thread %d exited" % threadid
s.tflock.acquire()
if threadid in s.threadframes: if threadid in s.threadframes:
print "Removing thread %d" % threadid print "Removing thread %d" % threadid
tf = s.threadframes[threadid] tf = s.threadframes[threadid]
tf.destroy() tf.setaccount("Unknown")
tf.setmessage("Idle")
s.availablethreadframes.append(tf)
del s.threadframes[threadid] del s.threadframes[threadid]
s.tflock.release()
def threadException(s, thread): def threadException(s, thread):
msg = "Thread '%s' terminated with exception:\n%s" % \ msg = "Thread '%s' terminated with exception:\n%s" % \