Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shrapnel
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
shrapnel
Commits
50a6acf8
Commit
50a6acf8
authored
Oct 10, 2013
by
Amit Dev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made linux_poller unaware of aio implementation details
parent
6b3cae38
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
29 deletions
+25
-29
coro/linux_aio.pyx
coro/linux_aio.pyx
+23
-14
coro/linux_poller.pyx
coro/linux_poller.pyx
+2
-15
No files found.
coro/linux_aio.pyx
View file @
50a6acf8
...
...
@@ -38,13 +38,14 @@ cdef enum:
BLOCK_SIZE
=
512
cdef
int
aio_eventfd
cdef
coro
aio_poller
cdef
io_context_t
aio_ioctx
cdef
dict
aio_event_map
cdef
iocb
aio_iocb
[
MAX_PENDING_REQS
]
cdef
aio_setup
():
cdef
int
res
global
aio_eventfd
,
aio_event_map
global
aio_eventfd
,
aio_
poller
,
aio_
event_map
res
=
io_setup
(
MAX_PENDING_REQS
,
&
aio_ioctx
)
if
res
:
...
...
@@ -52,24 +53,30 @@ cdef aio_setup():
aio_eventfd
=
eventfd
(
0
,
EFD_NONBLOCK
)
if
aio_eventfd
==
-
1
:
raise_oserror
()
the_poller
.
_register_fd
(
aio_eventfd
)
aio_event_map
=
{}
aio_poller
=
spawn
(
_aio_poll
)
cdef
aio_teardown
():
cdef
int
res
aio_poller
.
shutdown
()
close
(
aio_eventfd
)
res
=
io_destroy
(
aio_ioctx
)
if
res
:
raise_oserror_with_errno
(
res
)
close
(
aio_eventfd
)
cdef
aio_poll
():
def
_
aio_poll
():
cdef
int
r
,
fd
,
res
cdef
long
n
cdef
coro
co
cdef
io_event
aio_io_events
[
MAX_PENDING_REQS
]
while
1
:
try
:
the_poller
.
_wait_for_read
(
aio_eventfd
)
read
(
aio_eventfd
,
<
char
*>&
n
,
8
)
if
n
<
1
or
n
>
MAX_PENDING_REQS
:
raise_oserror
()
r
=
io_getevents
(
aio_ioctx
,
1
,
n
,
aio_io_events
,
NULL
)
if
r
<
0
:
raise_oserror
()
...
...
@@ -79,6 +86,8 @@ cdef aio_poll():
#print 'POLL: fd=%r, res=%r' % (fd, res)
co
=
aio_event_map
.
pop
(
fd
)
co
.
_schedule
(
res
)
except
Shutdown
:
break
cdef
_aligned_size
(
size
):
if
size
%
BLOCK_SIZE
:
...
...
coro/linux_poller.pyx
View file @
50a6acf8
...
...
@@ -218,11 +218,6 @@ cdef public class queue_poller [ object queue_poller_object, type queue_poller_t
me
=
the_scheduler
.
_current
target
=
me
add_to_map
=
True
IF
COMPILE_LINUX_AIO
:
if
ek
.
fd
==
aio_eventfd
:
add_to_map
=
False
if
add_to_map
:
self
.
event_map
[
ek
]
=
target
self
.
_register_event
(
ek
,
flags
)
...
...
@@ -295,13 +290,10 @@ cdef public class queue_poller [ object queue_poller_object, type queue_poller_t
return
self
.
_wait_for_with_eof
(
fd
,
EPOLLOUT
)
cdef
py_event
_wait_for
(
self
,
int
fd
,
int
events
):
self
.
_register_fd
(
fd
,
events
)
return
_YIELD
()
cdef
_register_fd
(
self
,
int
fd
,
events
=
EPOLLIN
):
cdef
event_key
ek
ek
=
event_key
(
events
,
fd
)
self
.
set_wait_for
(
ek
)
return
_YIELD
()
def
wait_for
(
self
,
int
fd
,
int
events
):
"""Wait for an event.
...
...
@@ -364,11 +356,6 @@ cdef public class queue_poller [ object queue_poller_object, type queue_poller_t
ek
=
event_key
(
new_e
.
events
,
new_e
.
data
.
fd
)
IF
COMPILE_LINUX_AIO
:
if
ek
.
fd
==
aio_eventfd
:
aio_poll
()
continue
try
:
co
=
self
.
event_map
[
ek
]
except
KeyError
:
...
...
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