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 #include "mojo/public/cpp/utility/run_loop.h" | 5 #include "mojo/public/cpp/utility/run_loop.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 19 matching lines...) Expand all Loading... |
30 MojoDeadline deadline; | 30 MojoDeadline deadline; |
31 }; | 31 }; |
32 | 32 |
33 struct RunLoop::RunState { | 33 struct RunLoop::RunState { |
34 RunState() : should_quit(false) {} | 34 RunState() : should_quit(false) {} |
35 | 35 |
36 bool should_quit; | 36 bool should_quit; |
37 }; | 37 }; |
38 | 38 |
39 RunLoop::RunLoop() | 39 RunLoop::RunLoop() |
40 : run_state_(NULL), next_handler_id_(0), next_sequence_number_(0) { | 40 : run_state_(nullptr), next_handler_id_(0), next_sequence_number_(0) { |
41 assert(!current()); | 41 assert(!current()); |
42 current_run_loop.Set(this); | 42 current_run_loop.Set(this); |
43 } | 43 } |
44 | 44 |
45 RunLoop::~RunLoop() { | 45 RunLoop::~RunLoop() { |
46 assert(current() == this); | 46 assert(current() == this); |
47 NotifyHandlers(MOJO_RESULT_ABORTED, IGNORE_DEADLINE); | 47 NotifyHandlers(MOJO_RESULT_ABORTED, IGNORE_DEADLINE); |
48 current_run_loop.Set(NULL); | 48 current_run_loop.Set(nullptr); |
49 } | 49 } |
50 | 50 |
51 // static | 51 // static |
52 void RunLoop::SetUp() { | 52 void RunLoop::SetUp() { |
53 current_run_loop.Allocate(); | 53 current_run_loop.Allocate(); |
54 } | 54 } |
55 | 55 |
56 // static | 56 // static |
57 void RunLoop::TearDown() { | 57 void RunLoop::TearDown() { |
58 assert(!current()); | 58 assert(!current()); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // std::priority_queue<> puts the least element at the end of the queue. We | 270 // std::priority_queue<> puts the least element at the end of the queue. We |
271 // want the soonest eligible task to be at the head of the queue, so | 271 // want the soonest eligible task to be at the head of the queue, so |
272 // run_times further in the future are considered lesser. | 272 // run_times further in the future are considered lesser. |
273 return run_time > other.run_time; | 273 return run_time > other.run_time; |
274 } | 274 } |
275 | 275 |
276 return sequence_number > other.sequence_number; | 276 return sequence_number > other.sequence_number; |
277 } | 277 } |
278 | 278 |
279 } // namespace mojo | 279 } // namespace mojo |
OLD | NEW |