Mir

Merge lp:~vanvugt/mir/rename-TimeSource-to-Clock into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 1313
Proposed branch: lp:~vanvugt/mir/rename-TimeSource-to-Clock
Merge into: lp:mir
Prerequisite: lp:~vanvugt/mir/compositor-report
Diff against target: 345 lines (+39/-39)
11 files modified
include/server/mir/default_server_configuration.h (+3/-3)
include/server/mir/logging/message_processor_report.h (+3/-3)
include/server/mir/time/clock.h (+6/-6)
include/server/mir/time/high_resolution_clock.h (+2/-2)
src/server/default_server_configuration.cpp (+3/-3)
src/server/logging/compositor_report.cpp (+1/-1)
src/server/logging/compositor_report.h (+3/-3)
src/server/logging/default_configuration.cpp (+1/-1)
src/server/logging/message_processor_report.cpp (+4/-4)
tests/unit-tests/logging/message_processor_report.cpp (+12/-12)
tests/unit-tests/logging/test_compositor_report.cpp (+1/-1)
To merge this branch: bzr merge lp:~vanvugt/mir/rename-TimeSource-to-Clock
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Abstain
Robert Carr (community) Abstain
Review via email: mp+200367@code.launchpad.net

Commit message

Rename TimeSource to Clock

Description of the change

"Clock" is a more widely understood word for describing that thing from which you get the time...

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

I would be mildly inclined to say a "Clock" is an implementation of a "TimeSource". I can't make a strong argument for any of the names here though.

review: Abstain
Revision history for this message
Kevin DuBois (kdub) wrote :

I don't see a strong reason to do this...
If we do though, lets update l27,208,236 to all be consistent

review: Abstain
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Better naming improves understanding and therefore maintainability. AFAIK all existing C and C++ interfaces for such functionality call it "clock".

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Maybe we should also rename namespace time to chrono too. ;)

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

AFAICT "chrono" and "time" are synonyms. The former derived from Greek, the latter from Old English. But once again, choose the word more people will understand :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/server/mir/default_server_configuration.h'
2--- include/server/mir/default_server_configuration.h 2013-12-20 08:04:42 +0000
3+++ include/server/mir/default_server_configuration.h 2014-01-06 02:59:24 +0000
4@@ -65,7 +65,7 @@
5 }
6 namespace time
7 {
8-class TimeSource;
9+class Clock;
10 }
11 namespace scene
12 {
13@@ -230,7 +230,7 @@
14 virtual std::shared_ptr<logging::Logger> the_logger();
15 /** @} */
16
17- virtual std::shared_ptr<time::TimeSource> the_time_source();
18+ virtual std::shared_ptr<time::Clock> the_clock();
19
20 protected:
21 using DefaultConfigurationOptions::the_options;
22@@ -283,7 +283,7 @@
23 CachedPtr<compositor::CompositorReport> compositor_report;
24 CachedPtr<logging::Logger> logger;
25 CachedPtr<graphics::DisplayReport> display_report;
26- CachedPtr<time::TimeSource> time_source;
27+ CachedPtr<time::Clock> clock;
28 CachedPtr<MainLoop> main_loop;
29 CachedPtr<ServerStatusListener> server_status_listener;
30 CachedPtr<graphics::DisplayConfigurationPolicy> display_configuration_policy;
31
32=== modified file 'include/server/mir/logging/message_processor_report.h'
33--- include/server/mir/logging/message_processor_report.h 2013-08-28 03:41:48 +0000
34+++ include/server/mir/logging/message_processor_report.h 2014-01-06 02:59:24 +0000
35@@ -20,7 +20,7 @@
36 #define MIR_LOGGING_MESSAGE_PROCESSOR_REPORT_H_
37
38 #include "mir/frontend/message_processor_report.h"
39-#include "mir/time/time_source.h"
40+#include "mir/time/clock.h"
41
42 #include <memory>
43 #include <mutex>
44@@ -56,7 +56,7 @@
45 public:
46 MessageProcessorReport(
47 std::shared_ptr<Logger> const& log,
48- std::shared_ptr<time::TimeSource> const& time_source);
49+ std::shared_ptr<time::Clock> const& clock);
50
51 void received_invocation(void const* mediator, int id, std::string const& method);
52
53@@ -74,7 +74,7 @@
54
55 private:
56 std::shared_ptr<Logger> const log;
57- std::shared_ptr<time::TimeSource> const time_source;
58+ std::shared_ptr<time::Clock> const clock;
59 std::mutex mutex;
60 detail::Mediators mediators;
61 };
62
63=== renamed file 'include/server/mir/time/time_source.h' => 'include/server/mir/time/clock.h'
64--- include/server/mir/time/time_source.h 2013-04-24 05:22:20 +0000
65+++ include/server/mir/time/clock.h 2014-01-06 02:59:24 +0000
66@@ -16,8 +16,8 @@
67 * Authored by: Thomas Voss <thomas.voss@canonical.com>
68 */
69
70-#ifndef MIR_TIME_TIME_SOURCE_H_
71-#define MIR_TIME_TIME_SOURCE_H_
72+#ifndef MIR_TIME_CLOCK_H_
73+#define MIR_TIME_CLOCK_H_
74
75 #include <chrono>
76
77@@ -28,17 +28,17 @@
78
79 typedef std::chrono::high_resolution_clock::time_point Timestamp;
80
81-class TimeSource
82+class Clock
83 {
84 public:
85- virtual ~TimeSource() = default;
86+ virtual ~Clock() = default;
87
88 virtual Timestamp sample() const = 0;
89
90 protected:
91- TimeSource() = default;
92+ Clock() = default;
93 };
94 }
95 }
96
97-#endif // MIR_TIME_TIME_SOURCE_H_
98+#endif // MIR_TIME_CLOCK_H_
99
100=== modified file 'include/server/mir/time/high_resolution_clock.h'
101--- include/server/mir/time/high_resolution_clock.h 2013-04-24 05:22:20 +0000
102+++ include/server/mir/time/high_resolution_clock.h 2014-01-06 02:59:24 +0000
103@@ -19,14 +19,14 @@
104 #ifndef MIR_TIME_HIGH_RESOLUTION_CLOCK_H_
105 #define MIR_TIME_HIGH_RESOLUTION_CLOCK_H_
106
107-#include "mir/time/time_source.h"
108+#include "mir/time/clock.h"
109
110 namespace mir
111 {
112 namespace time
113 {
114
115-class HighResolutionClock : public TimeSource
116+class HighResolutionClock : public Clock
117 {
118 public:
119 virtual Timestamp sample() const override;
120
121=== modified file 'src/server/default_server_configuration.cpp'
122--- src/server/default_server_configuration.cpp 2013-12-18 02:19:19 +0000
123+++ src/server/default_server_configuration.cpp 2014-01-06 02:59:24 +0000
124@@ -183,7 +183,7 @@
125 auto mp_report = the_options()->get(msg_processor_report_opt, off_opt_value);
126 if (mp_report == log_opt_value)
127 {
128- return std::make_shared<ml::MessageProcessorReport>(the_logger(), the_time_source());
129+ return std::make_shared<ml::MessageProcessorReport>(the_logger(), the_clock());
130 }
131 else if (mp_report == lttng_opt_value)
132 {
133@@ -222,9 +222,9 @@
134 return the_input_manager();
135 }
136
137-std::shared_ptr<mir::time::TimeSource> mir::DefaultServerConfiguration::the_time_source()
138+std::shared_ptr<mir::time::Clock> mir::DefaultServerConfiguration::the_clock()
139 {
140- return time_source(
141+ return clock(
142 []()
143 {
144 return std::make_shared<mir::time::HighResolutionClock>();
145
146=== modified file 'src/server/logging/compositor_report.cpp'
147--- src/server/logging/compositor_report.cpp 2014-01-02 09:10:38 +0000
148+++ src/server/logging/compositor_report.cpp 2014-01-06 02:59:24 +0000
149@@ -31,7 +31,7 @@
150
151 logging::CompositorReport::CompositorReport(
152 std::shared_ptr<Logger> const& logger,
153- std::shared_ptr<TimeSource> const& clock)
154+ std::shared_ptr<Clock> const& clock)
155 : logger(logger),
156 clock(clock),
157 last_report(now())
158
159=== modified file 'src/server/logging/compositor_report.h'
160--- src/server/logging/compositor_report.h 2014-01-02 09:10:38 +0000
161+++ src/server/logging/compositor_report.h 2014-01-06 02:59:24 +0000
162@@ -20,7 +20,7 @@
163 #define MIR_LOGGING_COMPOSITOR_REPORT_H_
164
165 #include "mir/compositor/compositor_report.h"
166-#include "mir/time/time_source.h"
167+#include "mir/time/clock.h"
168 #include <memory>
169 #include <mutex>
170 #include <unordered_map>
171@@ -37,7 +37,7 @@
172 {
173 public:
174 CompositorReport(std::shared_ptr<Logger> const& logger,
175- std::shared_ptr<time::TimeSource> const& clock);
176+ std::shared_ptr<time::Clock> const& clock);
177 void added_display(int width, int height, int x, int y, SubCompositorId id);
178 void began_frame(SubCompositorId id);
179 void finished_frame(SubCompositorId id);
180@@ -47,7 +47,7 @@
181
182 private:
183 std::shared_ptr<Logger> const logger;
184- std::shared_ptr<time::TimeSource> const clock;
185+ std::shared_ptr<time::Clock> const clock;
186
187 typedef time::Timestamp TimePoint;
188 TimePoint now() const;
189
190=== modified file 'src/server/logging/default_configuration.cpp'
191--- src/server/logging/default_configuration.cpp 2013-12-24 06:16:59 +0000
192+++ src/server/logging/default_configuration.cpp 2014-01-06 02:59:24 +0000
193@@ -81,7 +81,7 @@
194 if (the_options()->get(compositor_report_opt, off_opt_value) == log_opt_value)
195 {
196 return std::make_shared<ml::CompositorReport>(
197- the_logger(), the_time_source());
198+ the_logger(), the_clock());
199 }
200 else
201 {
202
203=== modified file 'src/server/logging/message_processor_report.cpp'
204--- src/server/logging/message_processor_report.cpp 2013-12-12 08:34:23 +0000
205+++ src/server/logging/message_processor_report.cpp 2014-01-06 02:59:24 +0000
206@@ -32,9 +32,9 @@
207
208 ml::MessageProcessorReport::MessageProcessorReport(
209 std::shared_ptr<Logger> const& log,
210- std::shared_ptr<time::TimeSource> const& time_source) :
211+ std::shared_ptr<time::Clock> const& clock) :
212 log(log),
213- time_source(time_source)
214+ clock(clock)
215 {
216 }
217
218@@ -79,13 +79,13 @@
219 auto& invocations = mediators[mediator].current_invocations;
220 auto& invocation = invocations[id];
221
222- invocation.start = time_source->sample();
223+ invocation.start = clock->sample();
224 invocation.method = method;
225 }
226
227 void ml::MessageProcessorReport::completed_invocation(void const* mediator, int id, bool result)
228 {
229- auto const end = time_source->sample();
230+ auto const end = clock->sample();
231 std::ostringstream out;
232
233 {
234
235=== modified file 'tests/unit-tests/logging/message_processor_report.cpp'
236--- tests/unit-tests/logging/message_processor_report.cpp 2013-03-28 14:20:06 +0000
237+++ tests/unit-tests/logging/message_processor_report.cpp 2014-01-06 02:59:24 +0000
238@@ -28,12 +28,12 @@
239
240 namespace
241 {
242-class MockTimeSource : public mir::time::TimeSource
243+class MockClock : public mir::time::Clock
244 {
245 public:
246 MOCK_CONST_METHOD0(sample, mir::time::Timestamp());
247
248- ~MockTimeSource() noexcept(true) {}
249+ ~MockClock() noexcept(true) {}
250 };
251
252 class MockLogger : public mir::logging::Logger
253@@ -45,13 +45,13 @@
254
255 struct MessageProcessorReport : public Test
256 {
257- MockLogger logger;
258- MockTimeSource time_source;
259+ MockLogger logger;
260+ MockClock clock;
261
262 mir::logging::MessageProcessorReport report;
263
264 MessageProcessorReport() :
265- report(mir::test::fake_shared(logger), mir::test::fake_shared(time_source))
266+ report(mir::test::fake_shared(logger), mir::test::fake_shared(clock))
267 {
268 EXPECT_CALL(logger, log(
269 mir::logging::Logger::debug,
270@@ -64,7 +64,7 @@
271 TEST_F(MessageProcessorReport, everything_fine)
272 {
273 mir::time::Timestamp a_time;
274- EXPECT_CALL(time_source, sample()).Times(2).WillRepeatedly(Return(a_time));
275+ EXPECT_CALL(clock, sample()).Times(2).WillRepeatedly(Return(a_time));
276 EXPECT_CALL(logger, log(
277 mir::logging::Logger::informational,
278 EndsWith(": a_function(), elapsed=0┬Ás"),
279@@ -79,7 +79,7 @@
280 mir::time::Timestamp a_time;
281 mir::time::Timestamp another_time = a_time + std::chrono::microseconds(1234);
282
283- EXPECT_CALL(time_source, sample()).Times(2)
284+ EXPECT_CALL(clock, sample()).Times(2)
285 .WillOnce(Return(a_time)).WillOnce(Return(another_time));
286
287 EXPECT_CALL(logger, log(
288@@ -94,7 +94,7 @@
289 TEST_F(MessageProcessorReport, reports_disconnect)
290 {
291 mir::time::Timestamp a_time;
292- EXPECT_CALL(time_source, sample()).Times(2).WillRepeatedly(Return(a_time));
293+ EXPECT_CALL(clock, sample()).Times(2).WillRepeatedly(Return(a_time));
294 EXPECT_CALL(logger, log(
295 mir::logging::Logger::informational,
296 HasSubstr("(disconnecting)"),
297@@ -109,7 +109,7 @@
298 const char* testError = "***Test error***";
299
300 mir::time::Timestamp a_time;
301- EXPECT_CALL(time_source, sample()).Times(2).WillRepeatedly(Return(a_time));
302+ EXPECT_CALL(clock, sample()).Times(2).WillRepeatedly(Return(a_time));
303 EXPECT_CALL(logger, log(
304 mir::logging::Logger::informational,
305 HasSubstr(testError),
306@@ -122,7 +122,7 @@
307
308 TEST_F(MessageProcessorReport, reports_unknown_method)
309 {
310- EXPECT_CALL(time_source, sample()).Times(0);
311+ EXPECT_CALL(clock, sample()).Times(0);
312 EXPECT_CALL(logger, log(
313 mir::logging::Logger::warning,
314 HasSubstr("UNKNOWN method=\"unknown_function_name\""),
315@@ -146,7 +146,7 @@
316 TEST_F(MessageProcessorReport, logs_a_debug_message_when_invocation_starts)
317 {
318 mir::time::Timestamp a_time;
319- EXPECT_CALL(time_source, sample()).Times(AnyNumber()).WillRepeatedly(Return(a_time));
320+ EXPECT_CALL(clock, sample()).Times(AnyNumber()).WillRepeatedly(Return(a_time));
321 EXPECT_CALL(logger, log(
322 mir::logging::Logger::informational,
323 HasSubstr("Calls outstanding on exit:"),
324@@ -163,7 +163,7 @@
325 TEST_F(MessageProcessorReport, logs_incomplete_calls_on_destruction)
326 {
327 mir::time::Timestamp a_time;
328- EXPECT_CALL(time_source, sample()).Times(AnyNumber()).WillRepeatedly(Return(a_time));
329+ EXPECT_CALL(clock, sample()).Times(AnyNumber()).WillRepeatedly(Return(a_time));
330
331 EXPECT_CALL(logger, log(
332 mir::logging::Logger::informational,
333
334=== modified file 'tests/unit-tests/logging/test_compositor_report.cpp'
335--- tests/unit-tests/logging/test_compositor_report.cpp 2013-12-24 08:07:27 +0000
336+++ tests/unit-tests/logging/test_compositor_report.cpp 2014-01-06 02:59:24 +0000
337@@ -28,7 +28,7 @@
338 namespace
339 {
340
341-class FakeClock : public time::TimeSource
342+class FakeClock : public time::Clock
343 {
344 public:
345 void elapse(chrono::microseconds delta)

Subscribers

People subscribed via source and target branches