OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # distutils language = c++ | 5 # distutils language = c++ |
6 | 6 |
7 cimport c_async_waiter | 7 cimport c_async_waiter |
8 cimport c_environment | 8 cimport c_environment |
9 cimport c_export # needed so the init function gets exported | 9 cimport c_export # needed so the init function gets exported |
10 cimport c_thunks | 10 cimport c_thunks |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 Post a task on the runloop. This must be called from the thread owning the | 50 Post a task on the runloop. This must be called from the thread owning the |
51 runloop. | 51 runloop. |
52 """ | 52 """ |
53 cdef c_environment.CClosure closure = c_environment.BuildClosure(runnable) | 53 cdef c_environment.CClosure closure = c_environment.BuildClosure(runnable) |
54 self.c_run_loop.PostDelayedTask(closure, delay) | 54 self.c_run_loop.PostDelayedTask(closure, delay) |
55 | 55 |
56 | 56 |
57 # We use a wrapping class to be able to call the C++ class PythonAsyncWaiter | 57 # We use a wrapping class to be able to call the C++ class PythonAsyncWaiter |
58 # across module boundaries. | 58 # across module boundaries. |
59 cdef class AsyncWaiter(object): | 59 cdef class AsyncWaiter(object): |
60 cdef c_environment.CEnvironment* _cenvironment | |
61 cdef c_async_waiter.PythonAsyncWaiter* _c_async_waiter | 60 cdef c_async_waiter.PythonAsyncWaiter* _c_async_waiter |
62 | 61 |
63 def __init__(self): | 62 def __init__(self): |
64 self._cenvironment = new c_environment.CEnvironment() | |
65 self._c_async_waiter = c_environment.NewAsyncWaiter() | 63 self._c_async_waiter = c_environment.NewAsyncWaiter() |
66 | 64 |
67 def __dealloc__(self): | 65 def __dealloc__(self): |
68 del self._c_async_waiter | 66 del self._c_async_waiter |
69 del self._cenvironment | |
70 | 67 |
71 def AsyncWait(self, handle, signals, deadline, callback): | 68 def AsyncWait(self, handle, signals, deadline, callback): |
72 return self._c_async_waiter.AsyncWait(handle, signals, deadline, callback) | 69 return self._c_async_waiter.AsyncWait(handle, signals, deadline, callback) |
73 | 70 |
74 def CancelWait(self, wait_id): | 71 def CancelWait(self, wait_id): |
75 self._c_async_waiter.CancelWait(wait_id) | 72 self._c_async_waiter.CancelWait(wait_id) |
OLD | NEW |