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): ...@@ -192,11 +192,11 @@ class Greenlet(greenlet):
if self._links and self._notifier is None: if self._links and self._notifier is None:
self._notifier = core.active_event(self._notify_links) 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""" """Must be called _exactly_ once for a greenlet to become active"""
return core.active_event(self.switch, *args) 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""" """Must be called _exactly_ once for a greenlet to become active"""
return core.timer(seconds, self.switch, *args) return core.timer(seconds, self.switch, *args)
...@@ -204,22 +204,22 @@ class Greenlet(greenlet): ...@@ -204,22 +204,22 @@ class Greenlet(greenlet):
def spawn(cls, function, *args, **kwargs): def spawn(cls, function, *args, **kwargs):
if kwargs: if kwargs:
g = cls(_switch_helper) g = cls(_switch_helper)
g.schedule_switch(function, args, kwargs) g.start(function, args, kwargs)
return g return g
else: else:
g = cls(function) g = cls(function)
g.schedule_switch(*args) g.start(*args)
return g return g
@classmethod @classmethod
def spawn_later(cls, seconds, function, *args, **kwargs): def spawn_later(cls, seconds, function, *args, **kwargs):
if kwargs: if kwargs:
g = cls(_switch_helper) g = cls(_switch_helper)
timer = g.schedule_switch_later(seconds, function, args, kwargs) timer = g.start_later(seconds, function, args, kwargs)
return g, timer return g, timer
else: else:
g = cls(function) g = cls(function)
timer = g.schedule_switch_later(seconds, *args) timer = g.start_later(seconds, *args)
return g, timer return g, timer
@classmethod @classmethod
......
...@@ -178,11 +178,11 @@ class Pool(GreenletSet): ...@@ -178,11 +178,11 @@ class Pool(GreenletSet):
return 1 return 1
return max(0, self.size - len(self) - len(self.waiting)) 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: if self.size is not None and len(self) >= self.size:
self.waiting.append((g, args)) self.waiting.append((g, args))
else: else:
g.schedule_switch(*args) g.start(*args)
self.add(g) self.add(g)
def spawn(self, function, *args, **kwargs): def spawn(self, function, *args, **kwargs):
...@@ -191,14 +191,14 @@ class Pool(GreenletSet): ...@@ -191,14 +191,14 @@ class Pool(GreenletSet):
args = (function, args, kwargs) args = (function, args, kwargs)
else: else:
g = Greenlet(function) g = Greenlet(function)
self.schedule_switch(g, *args) self.start(g, *args)
return g return g
def discard(self, p): def discard(self, p):
GreenletSet.discard(self, p) GreenletSet.discard(self, p)
while self.waiting and len(self) < self.size: while self.waiting and len(self) < self.size:
g, args = self.waiting.popleft() g, args = self.waiting.popleft()
g.schedule_switch(*args) g.start(*args)
self.add(g) 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