[pypy-commit] pypy continulet-pickle: Rename start_state into global_state.
arigo
noreply at buildbot.pypy.org
Mon Sep 12 15:44:57 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: continulet-pickle
Changeset: r47225:4c38c0864ce5
Date: 2011-09-12 15:44 +0200
http://bitbucket.org/pypy/pypy/changeset/4c38c0864ce5/
Log: Rename start_state into global_state.
diff --git a/pypy/module/_continuation/interp_continuation.py b/pypy/module/_continuation/interp_continuation.py
--- a/pypy/module/_continuation/interp_continuation.py
+++ b/pypy/module/_continuation/interp_continuation.py
@@ -21,16 +21,16 @@
def check_sthread(self):
ec = self.space.getexecutioncontext()
if ec.stacklet_thread is not self.sthread:
- start_state.clear()
+ global_state.clear()
raise geterror(self.space, "inter-thread support is missing")
return ec
def descr_init(self, w_callable, __args__):
if self.sthread is not None:
raise geterror(self.space, "continulet already __init__ialized")
- start_state.origin = self
- start_state.w_callable = w_callable
- start_state.args = __args__
+ global_state.origin = self
+ global_state.w_callable = w_callable
+ global_state.args = __args__
self.bottomframe = make_fresh_frame(self.space)
self.sthread = build_sthread(self.space)
try:
@@ -39,46 +39,46 @@
raise MemoryError
except MemoryError:
self.sthread = None
- start_state.clear()
+ global_state.clear()
raise getmemoryerror(self.space)
def switch(self, w_to):
to = self.space.interp_w(W_Continulet, w_to, can_be_None=True)
if to is not None:
if to.sthread is None:
- start_state.clear()
+ global_state.clear()
raise geterror(self.space, "continulet not initialized yet")
if self is to: # double-switch to myself: no-op
return get_result()
if self.sthread is None:
- start_state.clear()
+ global_state.clear()
raise geterror(self.space, "continulet not initialized yet")
ec = self.check_sthread()
#
- start_state.origin = self
+ global_state.origin = self
if to is None:
# simple switch: going to self.h
- start_state.destination = self
+ global_state.destination = self
else:
# double switch: the final destination is to.h
- start_state.destination = to
+ global_state.destination = to
#
- h = start_state.destination.h
+ h = global_state.destination.h
sthread = self.sthread
if sthread.is_empty_handle(h):
- start_state.clear()
+ global_state.clear()
raise geterror(self.space, "continulet already finished")
#
try:
do_switch(sthread, h)
except MemoryError:
- start_state.clear()
+ global_state.clear()
raise getmemoryerror(self.space)
#
return get_result()
def descr_switch(self, w_value=None, w_to=None):
- start_state.w_value = w_value
+ global_state.w_value = w_value
return self.switch(w_to)
def descr_throw(self, w_type, w_val=None, w_tb=None, w_to=None):
@@ -93,8 +93,8 @@
#
operr = OperationError(w_type, w_val, tb)
operr.normalize_exception(space)
- start_state.w_value = None
- start_state.propagate_exception = operr
+ global_state.w_value = None
+ global_state.propagate_exception = operr
return self.switch(w_to)
def descr_is_pending(self):
@@ -191,7 +191,7 @@
# ____________________________________________________________
-class StartState: # xxx a single global to pass around the function to start
+class GlobalState:
def clear(self):
self.origin = None
self.destination = None
@@ -199,15 +199,15 @@
self.args = None
self.w_value = None
self.propagate_exception = None
-start_state = StartState()
-start_state.clear()
+global_state = GlobalState()
+global_state.clear()
def new_stacklet_callback(h, arg):
- self = start_state.origin
- w_callable = start_state.w_callable
- args = start_state.args
- start_state.clear()
+ self = global_state.origin
+ w_callable = global_state.w_callable
+ args = global_state.args
+ global_state.clear()
try:
do_switch(self.sthread, h)
except MemoryError:
@@ -217,30 +217,30 @@
try:
assert self.sthread.ec.topframeref() is None
self.sthread.ec.topframeref = jit.non_virtual_ref(self.bottomframe)
- if start_state.propagate_exception is not None:
- raise start_state.propagate_exception # just propagate it further
- if start_state.w_value is not space.w_None:
+ if global_state.propagate_exception is not None:
+ raise global_state.propagate_exception # just propagate it further
+ if global_state.w_value is not space.w_None:
raise OperationError(space.w_TypeError, space.wrap(
"can't send non-None value to a just-started continulet"))
args = args.prepend(self.space.wrap(self))
w_result = space.call_args(w_callable, args)
except Exception, e:
- start_state.propagate_exception = e
+ global_state.propagate_exception = e
else:
- start_state.w_value = w_result
+ global_state.w_value = w_result
self.sthread.ec.topframeref = jit.vref_None
- start_state.origin = self
- start_state.destination = self
+ global_state.origin = self
+ global_state.destination = self
return self.h
def do_switch(sthread, h):
h = sthread.switch(h)
- origin = start_state.origin
- self = start_state.destination
- start_state.origin = None
- start_state.destination = None
+ origin = global_state.origin
+ self = global_state.destination
+ global_state.origin = None
+ global_state.destination = None
self.h, origin.h = origin.h, h
#
current = sthread.ec.topframeref
@@ -249,12 +249,12 @@
origin.bottomframe.f_backref = current
def get_result():
- if start_state.propagate_exception:
- e = start_state.propagate_exception
- start_state.propagate_exception = None
+ if global_state.propagate_exception:
+ e = global_state.propagate_exception
+ global_state.propagate_exception = None
raise e
- w_value = start_state.w_value
- start_state.w_value = None
+ w_value = global_state.w_value
+ global_state.w_value = None
return w_value
def build_sthread(space):
More information about the pypy-commit
mailing list