Quantcast
Channel: C++博客-所有随笔
Viewing all articles
Browse latest Browse all 7881

gevent::AsyncResult

$
0
0
看到 AsyncResult这个类,想到我之前自己写的处理异步返回值的类 

 1 class MutexObject:
 2     def __init__(self):
 3         self.mtx = threading.Condition()
 4         self.d = None
 5         
 6     def waitObject(self,timeout):
 7         d = None
 8         self.mtx.acquire()
 9         if self.d == None:
10             if timeout:
11                 self.mtx.wait(timeout)
12             else:
13                 self.mtx.wait()
14             d = self.d
15             self.d = None
16         self.mtx.release()
17         return d
18         
19     def notify(self,d):
20         self.mtx.acquire()
21         self.d = d
22         self.mtx.notify()
23         self.mtx.release()


放屁阿狗 2013-05-14 01:04 发表评论

Viewing all articles
Browse latest Browse all 7881

Trending Articles