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

Side by Side Diff: mojo/public/python/mojo_system_impl.pyx

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 months 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 unified diff | Download patch
« no previous file with comments | « mojo/public/python/mojo_system.pyx ('k') | mojo/public/python/rules.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 # distutils language = c++
6
7 cimport c_async_waiter
8 cimport c_environment
9 cimport c_export # needed so the init function gets exported
10 cimport c_thunks
11
12
13 from libc.stdint cimport uintptr_t
14
15
16 def SetSystemThunks(system_thunks_as_object):
17 """Bind the basic Mojo Core functions.
18 """
19 cdef const c_thunks.MojoSystemThunks* system_thunks = (
20 <const c_thunks.MojoSystemThunks*><uintptr_t>system_thunks_as_object)
21 c_thunks.MojoSetSystemThunks(system_thunks)
22
23
24 cdef class RunLoop(object):
25 """RunLoop to use when using asynchronous operations on handles."""
26
27 cdef c_environment.CRunLoop* c_run_loop
28
29 def __init__(self):
30 assert not <uintptr_t>(c_environment.CRunLoopCurrent())
31 self.c_run_loop = new c_environment.CRunLoop()
32
33 def __dealloc__(self):
34 del self.c_run_loop
35
36 def Run(self):
37 """Run the runloop until Quit is called."""
38 self.c_run_loop.Run()
39
40 def RunUntilIdle(self):
41 """Run the runloop until Quit is called or no operation is waiting."""
42 self.c_run_loop.RunUntilIdle()
43
44 def Quit(self):
45 """Quit the runloop."""
46 self.c_run_loop.Quit()
47
48 def PostDelayedTask(self, runnable, delay=0):
49 """
50 Post a task on the runloop. This must be called from the thread owning the
51 runloop.
52 """
53 cdef c_environment.CClosure closure = c_environment.BuildClosure(runnable)
54 self.c_run_loop.PostDelayedTask(closure, delay)
55
56
57 # We use a wrapping class to be able to call the C++ class PythonAsyncWaiter
58 # across module boundaries.
59 cdef class AsyncWaiter(object):
60 cdef c_async_waiter.PythonAsyncWaiter* _c_async_waiter
61
62 def __init__(self):
63 self._c_async_waiter = c_environment.NewAsyncWaiter()
64
65 def __dealloc__(self):
66 del self._c_async_waiter
67
68 def AsyncWait(self, handle, signals, deadline, callback):
69 return self._c_async_waiter.AsyncWait(handle, signals, deadline, callback)
70
71 def CancelWait(self, wait_id):
72 self._c_async_waiter.CancelWait(wait_id)
OLDNEW
« no previous file with comments | « mojo/public/python/mojo_system.pyx ('k') | mojo/public/python/rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698