Commit c435b2fa authored by Denis Bilenko's avatar Denis Bilenko

rename Greenlet.schedule_switch and Greenlet.schedule_switch_later to...

rename Greenlet.schedule_switch and Greenlet.schedule_switch_later to Greenlet.start and Greenlet.start_later
parent 0cfded8b
......@@ -192,11 +192,11 @@ class Greenlet(greenlet):
if self._links and self._notifier is None:
self._notifier = core.active_event(self._notify_links)
def schedule_switch(self, *args):
def start(self, *args):
"""Must be called _exactly_ once for a greenlet to become active"""
return core.active_event(self.switch, *args)
def schedule_switch_later(self, seconds, *args):
def start_later(self, seconds, *args):
"""Must be called _exactly_ once for a greenlet to become active"""
return core.timer(seconds, self.switch, *args)
......@@ -204,22 +204,22 @@ class Greenlet(greenlet):
def spawn(cls, function, *args, **kwargs):
if kwargs:
g = cls(_switch_helper)
g.schedule_switch(function, args, kwargs)
g.start(function, args, kwargs)
return g
else:
g = cls(function)
g.schedule_switch(*args)
g.start(*args)
return g
@classmethod
def spawn_later(cls, seconds, function, *args, **kwargs):
if kwargs:
g = cls(_switch_helper)
timer = g.schedule_switch_later(seconds, function, args, kwargs)
timer = g.start_later(seconds, function, args, kwargs)
return g, timer
else:
g = cls(function)
timer = g.schedule_switch_later(seconds, *args)
timer = g.start_later(seconds, *args)
return g, timer
@classmethod
......
......@@ -178,11 +178,11 @@ class Pool(GreenletSet):
return 1
return max(0, self.size - len(self) - len(self.waiting))
def schedule_switch(self, g, *args):
def start(self, g, *args):
if self.size is not None and len(self) >= self.size:
self.waiting.append((g, args))
else:
g.schedule_switch(*args)
g.start(*args)
self.add(g)
def spawn(self, function, *args, **kwargs):
......@@ -191,14 +191,14 @@ class Pool(GreenletSet):
args = (function, args, kwargs)
else:
g = Greenlet(function)
self.schedule_switch(g, *args)
self.start(g, *args)
return g
def discard(self, p):
GreenletSet.discard(self, p)
while self.waiting and len(self) < self.size:
g, args = self.waiting.popleft()
g.schedule_switch(*args)
g.start(*args)
self.add(g)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment