Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1118)

Unified Diff: mojo/public/python/mojo/system.pyx

Issue 795593004: Update mojo sdk to rev cc531b32182099a5a034a99daff35ed5d38a61c8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More workarounds for MSVC Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/python/mojo/c_thunks.pxd ('k') | mojo/public/python/mojo/system_impl.pyx » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/python/mojo/system.pyx
diff --git a/mojo/public/python/mojo/system.pyx b/mojo/public/python/mojo/system.pyx
index 35b8093fd8ae402a09909dd74c1c68f2cbc68ad0..2533babe672c4b56d45ddc8b2280e4eb5b89c04c 100644
--- a/mojo/public/python/mojo/system.pyx
+++ b/mojo/public/python/mojo/system.pyx
@@ -5,6 +5,8 @@
# distutils language = c++
cimport c_core
+cimport c_export # needed so the init function gets exported
+cimport c_thunks
from cpython.buffer cimport PyBUF_CONTIG
@@ -27,10 +29,9 @@ def SetSystemThunks(system_thunks_as_object):
This should only be used by the embedder.
"""
- cdef const c_core.MojoSystemThunks* system_thunks = (
- <const c_core.MojoSystemThunks*><uintptr_t>system_thunks_as_object)
- c_core.MojoSetSystemThunks(system_thunks)
- mojo.system_impl.SetSystemThunks(system_thunks_as_object)
+ cdef const c_thunks.MojoSystemThunks* system_thunks = (
+ <const c_thunks.MojoSystemThunks*><uintptr_t>system_thunks_as_object)
+ c_thunks.MojoSetSystemThunks(system_thunks)
HANDLE_INVALID = c_core.MOJO_HANDLE_INVALID
RESULT_OK = c_core.MOJO_RESULT_OK
@@ -68,6 +69,9 @@ READ_DATA_FLAG_QUERY = c_core.MOJO_READ_DATA_FLAG_QUERY
READ_DATA_FLAG_PEEK = c_core.MOJO_READ_DATA_FLAG_PEEK
MAP_BUFFER_FLAG_NONE = c_core.MOJO_MAP_BUFFER_FLAG_NONE
+_WAITMANY_NO_SIGNAL_STATE_ERRORS = [RESULT_INVALID_ARGUMENT,
+ RESULT_RESOURCE_EXHAUSTED]
+
def GetTimeTicksNow():
"""Monotonically increasing tick count representing "right now."
@@ -202,13 +206,19 @@ def WaitMany(handles_and_signals, deadline):
See mojo/public/c/system/functions.h
"""
cdef uint32_t length = len(handles_and_signals)
+ cdef uint32_t result_index = <uint32_t>(-1)
+
cdef _ScopedMemory handles_alloc = _ScopedMemory(
sizeof(c_core.MojoHandle) * length)
cdef _ScopedMemory signals_alloc = _ScopedMemory(
sizeof(c_core.MojoHandleSignals) * length)
+ cdef _ScopedMemory states_alloc = _ScopedMemory(
+ sizeof(c_core.MojoHandleSignalsState) * length)
cdef c_core.MojoHandle* handles = <c_core.MojoHandle*>handles_alloc.memory
cdef c_core.MojoHandleSignals* signals = (
<c_core.MojoHandleSignals*>signals_alloc.memory)
+ cdef c_core.MojoHandleSignalsState* states = (
+ <c_core.MojoHandleSignalsState*>states_alloc.memory)
cdef int index = 0
for (h, s) in handles_and_signals:
handles[index] = (<Handle?>h)._mojo_handle
@@ -217,8 +227,20 @@ def WaitMany(handles_and_signals, deadline):
cdef c_core.MojoResult result = c_core.MOJO_RESULT_OK
cdef c_core.MojoDeadline cdeadline = deadline
with nogil:
- result = c_core.MojoWaitMany(handles, signals, length, cdeadline)
- return result
+ result = c_core.MojoWaitMany(handles, signals, length, cdeadline,
+ &result_index, states)
+
+ returned_result_index = None
+ if result_index != <uint32_t>(-1):
+ returned_result_index = result_index
+
+ returned_states = None
+ if result not in _WAITMANY_NO_SIGNAL_STATE_ERRORS:
+ returned_states = [(states[i].satisfied_signals,
+ states[i].satisfiable_signals) for i in xrange(length)]
+
+ return (result, returned_result_index, returned_states)
+
cdef class DataPipeTwoPhaseBuffer(object):
"""Return value for two phases read and write.
@@ -340,10 +362,17 @@ cdef class Handle(object):
cdef c_core.MojoHandle handle = self._mojo_handle
cdef c_core.MojoHandleSignals csignals = signals
cdef c_core.MojoDeadline cdeadline = deadline
+ cdef c_core.MojoHandleSignalsState signal_states
cdef c_core.MojoResult result
with nogil:
- result = c_core.MojoWait(handle, csignals, cdeadline)
- return result
+ result = c_core.MojoWait(handle, csignals, cdeadline, &signal_states)
+
+ returned_states = None
+ if result not in _WAITMANY_NO_SIGNAL_STATE_ERRORS:
+ returned_states = (signal_states.satisfied_signals,
+ signal_states.satisfiable_signals)
+
+ return (result, returned_states)
def AsyncWait(self, signals, deadline, callback):
cdef c_core.MojoHandle handle = self._mojo_handle
@@ -772,4 +801,4 @@ class RunLoop(object):
return None
-_ASYNC_WAITER = mojo.system_impl.ASYNC_WAITER
+_ASYNC_WAITER = mojo.system_impl.AsyncWaiter()
« no previous file with comments | « mojo/public/python/mojo/c_thunks.pxd ('k') | mojo/public/python/mojo/system_impl.pyx » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698