Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
82f34140
Commit
82f34140
authored
Jan 22, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move start into the watcher base.
parent
b2ef20c4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
49 deletions
+25
-49
src/gevent/libev/corecext.ppyx
src/gevent/libev/corecext.ppyx
+25
-49
No files found.
src/gevent/libev/corecext.ppyx
View file @
82f34140
...
@@ -665,11 +665,9 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -665,11 +665,9 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
# bit #2 set if ev_unref() was called and we must call ev_ref() later
# bit #2 set if ev_unref() was called and we must call ev_ref() later
# bit #3 set if user wants to call ev_unref() before start()
# bit #3 set if user wants to call ev_unref() before start()
#define WATCHER
_BASE
(TYPE) \
#define WATCHER(TYPE) \
cdef libev.ev_##TYPE _watcher \
cdef libev.ev_##TYPE _watcher \
\
\
\
\
def stop(self): \
def stop(self): \
_check_loop(self.loop) \
_check_loop(self.loop) \
if self._flags & 2: \
if self._flags & 2: \
...
@@ -689,27 +687,11 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -689,27 +687,11 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
self.args = args \
self.args = args \
LIBEV_UNREF \
LIBEV_UNREF \
libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) \
libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) \
PYTHON_INCREF
PYTHON_INCREF \
#define START(TYPE) def start(self, object callback, *args): \
_check_loop(self.loop) \
if callback is None: \
raise TypeError('callback must be callable, not None') \
self.callback = callback \
self.args = args \
LIBEV_UNREF \
libev.ev_##TYPE##_start(self.loop._ptr, &self._watcher) \
PYTHON_INCREF
#define WATCHER(TYPE) WATCHER_BASE(TYPE) \
\
\
START(TYPE) \
cdef void _do_libev_start(self): \
libev.ev_##TYPE##_start(self.loop._ptr, &self._watcher)
#define COMMA ,
cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Type]:
cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Type]:
...
@@ -780,6 +762,20 @@ cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Ty
...
@@ -780,6 +762,20 @@ cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Ty
def pending(self):
def pending(self):
return True if libev.ev_is_pending(self.__watcher) else False
return True if libev.ev_is_pending(self.__watcher) else False
def start(self, object callback, *args):
_check_loop(self.loop)
if callback is None:
raise TypeError("Expected a callable, not None")
self.callback = callback
self.args = args
LIBEV_UNREF
self._do_libev_start()
PYTHON_INCREF
cdef void _do_libev_start(self):
# This is not allowed to fail, and must be implemented by subclasses.
return
def __repr__(self):
def __repr__(self):
if Py_ReprEnter(<PyObjectPtr>self) != 0:
if Py_ReprEnter(<PyObjectPtr>self) != 0:
return "<...>"
return "<...>"
...
@@ -814,21 +810,12 @@ cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Ty
...
@@ -814,21 +810,12 @@ cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Ty
cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
WATCHER
_BASE
(io)
WATCHER(io)
def start(self, object callback, *args, pass_events=False):
def start(self, object callback, *args, pass_events=False):
_check_loop(self.loop)
if callback is None:
raise TypeError('callback must be callable, not None')
self.callback = callback
if pass_events:
if pass_events:
self.args = (GEVENT_CORE_EVENTS, ) + args
args = (GEVENT_CORE_EVENTS, ) + args
else:
watcher.start(self, callback, *args)
self.args = args
LIBEV_UNREF
libev.ev_io_start(self.loop._ptr, &self._watcher)
PYTHON_INCREF
cpdef __posix_cinit(self, loop loop, int fd, int events, ref=True, priority=None):
cpdef __posix_cinit(self, loop loop, int fd, int events, ref=True, priority=None):
if fd < 0:
if fd < 0:
...
@@ -904,24 +891,16 @@ cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
...
@@ -904,24 +891,16 @@ cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer_Type]:
cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer_Type]:
WATCHER
_BASE
(timer)
WATCHER(timer)
update_loop_time_on_start = False
update_loop_time_on_start = False
def start(self, object callback, *args, update=None):
def start(self, object callback, *args, update=None):
_check_loop(self.loop)
if callback is None:
raise TypeError('callback must be callable, not None')
self.callback = callback
self.args = args
LIBEV_UNREF
if update is None:
if update is None:
update = self.update_loop_time_on_start
update = self.update_loop_time_on_start
if update:
if update:
libev.ev_now_update(self.loop._ptr)
libev.ev_now_update(self.loop._ptr)
libev.ev_timer_start(self.loop._ptr, &self._watcher)
watcher.start(self, callback, *args)
PYTHON_INCREF
def __cinit__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None):
def __cinit__(self, loop loop, double after=0.0, double repeat=0.0, ref=True, priority=None):
if repeat < 0.0:
if repeat < 0.0:
...
@@ -1007,10 +986,7 @@ cdef public class fork(watcher) [object PyGeventForkObject, type PyGeventFork_Ty
...
@@ -1007,10 +986,7 @@ cdef public class fork(watcher) [object PyGeventForkObject, type PyGeventFork_Ty
cdef public class async_(watcher) [object PyGeventAsyncObject, type PyGeventAsync_Type]:
cdef public class async_(watcher) [object PyGeventAsyncObject, type PyGeventAsync_Type]:
WATCHER_BASE(async)
WATCHER(async)
START(async)
@property
@property
def pending(self):
def pending(self):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment