[pypy-svn] r28776 - pypy/dist/pypy/module/_stackless
arigo at codespeak.net
arigo at codespeak.net
Wed Jun 14 17:30:00 CEST 2006
Author: arigo
Date: Wed Jun 14 17:29:59 2006
New Revision: 28776
Modified:
pypy/dist/pypy/module/_stackless/coroutine.py
pypy/dist/pypy/module/_stackless/interp_coroutine.py
pypy/dist/pypy/module/_stackless/interp_greenlet.py
Log:
Replace CoState.last with attributes on the syncstate.
Modified: pypy/dist/pypy/module/_stackless/coroutine.py
==============================================================================
--- pypy/dist/pypy/module/_stackless/coroutine.py (original)
+++ pypy/dist/pypy/module/_stackless/coroutine.py Wed Jun 14 17:29:59 2006
@@ -264,4 +264,4 @@
self.space = space
def post_install(self):
- self.current = self.main = self.last = AppCoroutine(self.space, is_main=True)
+ self.current = self.main = AppCoroutine(self.space, is_main=True)
Modified: pypy/dist/pypy/module/_stackless/interp_coroutine.py
==============================================================================
--- pypy/dist/pypy/module/_stackless/interp_coroutine.py (original)
+++ pypy/dist/pypy/module/_stackless/interp_coroutine.py Wed Jun 14 17:29:59 2006
@@ -63,15 +63,17 @@
class BaseCoState(object):
def __init__(self):
- self.current = self.main = self.last = None
+ self.current = self.main = None
def __repr__(self):
"NOT_RPYTHON"
# for debugging only
- return '<%s last=%r current=%r>' % (self.__class__.__name__,
- self.last, self.current)
+ return '<%s current=%r>' % (self.__class__.__name__, self.current)
+
def update(self, new):
- self.last, self.current = self.current, new
+ syncstate.leaving = self.current
+ syncstate.entering = new
+ self.current = new
frame, new.frame = new.frame, None
return frame
@@ -79,7 +81,7 @@
class CoState(BaseCoState):
def __init__(self):
BaseCoState.__init__(self)
- self.last = self.current = self.main = Coroutine(self)
+ self.current = self.main = Coroutine(self)
class CoroutineDamage(SystemError):
pass
@@ -91,10 +93,25 @@
def reset(self):
self.default_costate = None
+ self.leaving = None
+ self.entering = None
self.things_to_do = False
self.temp_exc = None
self.to_delete = []
+ def switched(self, incoming_frame):
+ left = syncstate.leaving
+ entered = syncstate.entering
+ syncstate.leaving = syncstate.entering = None
+ if left is not None: # mostly to work around an annotation problem;
+ # should not really be None
+ left.frame = incoming_frame
+ left.goodbye()
+ if entered is not None:
+ entered.hello()
+ if self.things_to_do:
+ self._do_things_to_do()
+
def check_for_zombie(self, obj):
return co in self.to_delete
@@ -102,11 +119,6 @@
self.to_delete.append(obj)
self.things_to_do = True
- def do_things_to_do(self):
- # inlineable stub
- if self.things_to_do:
- self._do_things_to_do()
-
def _do_things_to_do(self):
if self.temp_exc is not None:
# somebody left an unhandled exception and switched to us.
@@ -197,13 +209,9 @@
return self._execute(incoming_frame)
def _execute(self, incoming_frame):
+ syncstate.switched(incoming_frame)
state = self.costate
- left = state.last
- left.frame = incoming_frame
- left.goodbye()
- self.hello()
try:
- syncstate.do_things_to_do()
try:
self.thunk.call()
finally:
@@ -230,11 +238,7 @@
state = self.costate
incoming_frame = state.update(self).switch()
resume_point("coroutine_switch", self, state, returns=incoming_frame)
- left = state.last
- left.frame = incoming_frame
- left.goodbye()
- state.current.hello()
- syncstate.do_things_to_do()
+ syncstate.switched(incoming_frame)
def kill(self):
if self.frame is None:
Modified: pypy/dist/pypy/module/_stackless/interp_greenlet.py
==============================================================================
--- pypy/dist/pypy/module/_stackless/interp_greenlet.py (original)
+++ pypy/dist/pypy/module/_stackless/interp_greenlet.py Wed Jun 14 17:29:59 2006
@@ -43,7 +43,7 @@
self.operr = None
def post_install(self):
- self.current = self.main = self.last = AppGreenlet(self.space, is_main=True)
+ self.current = self.main = AppGreenlet(self.space, is_main=True)
class GreenletExit(Exception):
pass
More information about the Pypy-commit
mailing list