def __init__(self, read, write): Thread.__init__(self) self.xmitbuf = JdwpBuffer() self.recvbuf = JdwpBuffer() self._read = read self.write = write self.initialized = False self.next_id = 3 self.bindqueue = Queue() self.qmap = {} self.rmap = {} self.xmitlock = Lock()
def __init__(self, read, write): Thread.__init__(self) self.xmitbuf = JdwpBuffer() #具体实现在jdwp文件中,用C语言实现,这块需要了解C语言嵌入python语言的知识 self.recvbuf = JdwpBuffer() self._read = read self.write = write self.initialized = False self.next_id = 3 #下一个请求id,『可能每次请求都是有序号的』 self.bindqueue = Queue() #定义一个先进先出的队列 self.qmap = {} #初始化一个空的字典 self.rmap = {} #初始化一个空的字典 self.xmitlock = Lock() #是一个互斥锁
def processResponse(self, ident, code, data): 'internal to the i/o thread w/ recv ctrl; processes incoming response' chan = self.qmap.pop(ident, None) if not chan: return buf = JdwpBuffer() buf.config(*self.sizes) buf.prepareUnpack(data) return chan.put((code, buf))
def processRequest(self, ident, code, data): 'internal to the i/o thread w/ recv ctrl; processes incoming request' chan = self.rmap.get(code) if not chan: return #TODO buf = JdwpBuffer() buf.config(*self.sizes) buf.prepareUnpack(data) return chan.put((ident, buf))
def processResponse(self, ident, code, data): 'internal to the i/o thread w/ recv ctrl; processes incoming response' log.debug("study", "In Connection.processResponse ident=" + str(ident) + "\t code=" + str(code) + "\t data=") chan = self.qmap.pop(ident, None) #从字典中读取,并删除该数据 if not chan: return buf = JdwpBuffer() buf.config(*self.sizes) buf.prepareUnpack(data) return chan.put((code, buf))
def processRequest(self, ident, code, data): 'internal to the i/o thread w/ recv ctrl; processes incoming request' log.debug("study", "In Connection.processRequest ident=" + str(ident) + "\t code=" + str(code) + "\t data=") chan = self.rmap.get(code) #所有中断都由该chan队列处理,每次只是从rmap读出内容,而没有将rmap对应的chan清除 if not chan: return #TODO buf = JdwpBuffer() buf.config(*self.sizes) buf.prepareUnpack(data) return chan.put((ident, buf)) #将解析后的数据压入队列中
def buffer(self): 'returns a JdwpBuffer configured for this connection' buf = JdwpBuffer() buf.config(*self.sizes) return buf