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
=== modified file 'include/server/mir/default_server_configuration.h'
--- include/server/mir/default_server_configuration.h 2013-12-20 08:04:42 +0000
+++ include/server/mir/default_server_configuration.h 2014-01-06 02:59:24 +0000
@@ -65,7 +65,7 @@
65}65}
66namespace time66namespace time
67{67{
68class TimeSource;68class Clock;
69}69}
70namespace scene70namespace scene
71{71{
@@ -230,7 +230,7 @@
230 virtual std::shared_ptr<logging::Logger> the_logger();230 virtual std::shared_ptr<logging::Logger> the_logger();
231 /** @} */231 /** @} */
232232
233 virtual std::shared_ptr<time::TimeSource> the_time_source();233 virtual std::shared_ptr<time::Clock> the_clock();
234234
235protected:235protected:
236 using DefaultConfigurationOptions::the_options;236 using DefaultConfigurationOptions::the_options;
@@ -283,7 +283,7 @@
283 CachedPtr<compositor::CompositorReport> compositor_report;283 CachedPtr<compositor::CompositorReport> compositor_report;
284 CachedPtr<logging::Logger> logger;284 CachedPtr<logging::Logger> logger;
285 CachedPtr<graphics::DisplayReport> display_report;285 CachedPtr<graphics::DisplayReport> display_report;
286 CachedPtr<time::TimeSource> time_source;286 CachedPtr<time::Clock> clock;
287 CachedPtr<MainLoop> main_loop;287 CachedPtr<MainLoop> main_loop;
288 CachedPtr<ServerStatusListener> server_status_listener;288 CachedPtr<ServerStatusListener> server_status_listener;
289 CachedPtr<graphics::DisplayConfigurationPolicy> display_configuration_policy;289 CachedPtr<graphics::DisplayConfigurationPolicy> display_configuration_policy;
290290
=== modified file 'include/server/mir/logging/message_processor_report.h'
--- include/server/mir/logging/message_processor_report.h 2013-08-28 03:41:48 +0000
+++ include/server/mir/logging/message_processor_report.h 2014-01-06 02:59:24 +0000
@@ -20,7 +20,7 @@
20#define MIR_LOGGING_MESSAGE_PROCESSOR_REPORT_H_20#define MIR_LOGGING_MESSAGE_PROCESSOR_REPORT_H_
2121
22#include "mir/frontend/message_processor_report.h"22#include "mir/frontend/message_processor_report.h"
23#include "mir/time/time_source.h"23#include "mir/time/clock.h"
2424
25#include <memory>25#include <memory>
26#include <mutex>26#include <mutex>
@@ -56,7 +56,7 @@
56public:56public:
57 MessageProcessorReport(57 MessageProcessorReport(
58 std::shared_ptr<Logger> const& log,58 std::shared_ptr<Logger> const& log,
59 std::shared_ptr<time::TimeSource> const& time_source);59 std::shared_ptr<time::Clock> const& clock);
6060
61 void received_invocation(void const* mediator, int id, std::string const& method);61 void received_invocation(void const* mediator, int id, std::string const& method);
6262
@@ -74,7 +74,7 @@
7474
75private:75private:
76 std::shared_ptr<Logger> const log;76 std::shared_ptr<Logger> const log;
77 std::shared_ptr<time::TimeSource> const time_source;77 std::shared_ptr<time::Clock> const clock;
78 std::mutex mutex;78 std::mutex mutex;
79 detail::Mediators mediators;79 detail::Mediators mediators;
80};80};
8181
=== renamed file 'include/server/mir/time/time_source.h' => 'include/server/mir/time/clock.h'
--- include/server/mir/time/time_source.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/time/clock.h 2014-01-06 02:59:24 +0000
@@ -16,8 +16,8 @@
16 * Authored by: Thomas Voss <thomas.voss@canonical.com>16 * Authored by: Thomas Voss <thomas.voss@canonical.com>
17 */17 */
1818
19#ifndef MIR_TIME_TIME_SOURCE_H_19#ifndef MIR_TIME_CLOCK_H_
20#define MIR_TIME_TIME_SOURCE_H_20#define MIR_TIME_CLOCK_H_
2121
22#include <chrono>22#include <chrono>
2323
@@ -28,17 +28,17 @@
2828
29typedef std::chrono::high_resolution_clock::time_point Timestamp;29typedef std::chrono::high_resolution_clock::time_point Timestamp;
3030
31class TimeSource31class Clock
32{32{
33public:33public:
34 virtual ~TimeSource() = default;34 virtual ~Clock() = default;
3535
36 virtual Timestamp sample() const = 0;36 virtual Timestamp sample() const = 0;
3737
38protected:38protected:
39 TimeSource() = default;39 Clock() = default;
40};40};
41}41}
42}42}
4343
44#endif // MIR_TIME_TIME_SOURCE_H_44#endif // MIR_TIME_CLOCK_H_
4545
=== modified file 'include/server/mir/time/high_resolution_clock.h'
--- include/server/mir/time/high_resolution_clock.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/time/high_resolution_clock.h 2014-01-06 02:59:24 +0000
@@ -19,14 +19,14 @@
19#ifndef MIR_TIME_HIGH_RESOLUTION_CLOCK_H_19#ifndef MIR_TIME_HIGH_RESOLUTION_CLOCK_H_
20#define MIR_TIME_HIGH_RESOLUTION_CLOCK_H_20#define MIR_TIME_HIGH_RESOLUTION_CLOCK_H_
2121
22#include "mir/time/time_source.h"22#include "mir/time/clock.h"
2323
24namespace mir24namespace mir
25{25{
26namespace time26namespace time
27{27{
2828
29class HighResolutionClock : public TimeSource29class HighResolutionClock : public Clock
30{30{
31public:31public:
32 virtual Timestamp sample() const override;32 virtual Timestamp sample() const override;
3333
=== modified file 'src/server/default_server_configuration.cpp'
--- src/server/default_server_configuration.cpp 2013-12-18 02:19:19 +0000
+++ src/server/default_server_configuration.cpp 2014-01-06 02:59:24 +0000
@@ -183,7 +183,7 @@
183 auto mp_report = the_options()->get(msg_processor_report_opt, off_opt_value);183 auto mp_report = the_options()->get(msg_processor_report_opt, off_opt_value);
184 if (mp_report == log_opt_value)184 if (mp_report == log_opt_value)
185 {185 {
186 return std::make_shared<ml::MessageProcessorReport>(the_logger(), the_time_source());186 return std::make_shared<ml::MessageProcessorReport>(the_logger(), the_clock());
187 }187 }
188 else if (mp_report == lttng_opt_value)188 else if (mp_report == lttng_opt_value)
189 {189 {
@@ -222,9 +222,9 @@
222 return the_input_manager();222 return the_input_manager();
223}223}
224224
225std::shared_ptr<mir::time::TimeSource> mir::DefaultServerConfiguration::the_time_source()225std::shared_ptr<mir::time::Clock> mir::DefaultServerConfiguration::the_clock()
226{226{
227 return time_source(227 return clock(
228 []()228 []()
229 {229 {
230 return std::make_shared<mir::time::HighResolutionClock>();230 return std::make_shared<mir::time::HighResolutionClock>();
231231
=== modified file 'src/server/logging/compositor_report.cpp'
--- src/server/logging/compositor_report.cpp 2014-01-02 09:10:38 +0000
+++ src/server/logging/compositor_report.cpp 2014-01-06 02:59:24 +0000
@@ -31,7 +31,7 @@
3131
32logging::CompositorReport::CompositorReport(32logging::CompositorReport::CompositorReport(
33 std::shared_ptr<Logger> const& logger,33 std::shared_ptr<Logger> const& logger,
34 std::shared_ptr<TimeSource> const& clock)34 std::shared_ptr<Clock> const& clock)
35 : logger(logger),35 : logger(logger),
36 clock(clock),36 clock(clock),
37 last_report(now())37 last_report(now())
3838
=== modified file 'src/server/logging/compositor_report.h'
--- src/server/logging/compositor_report.h 2014-01-02 09:10:38 +0000
+++ src/server/logging/compositor_report.h 2014-01-06 02:59:24 +0000
@@ -20,7 +20,7 @@
20#define MIR_LOGGING_COMPOSITOR_REPORT_H_20#define MIR_LOGGING_COMPOSITOR_REPORT_H_
2121
22#include "mir/compositor/compositor_report.h"22#include "mir/compositor/compositor_report.h"
23#include "mir/time/time_source.h"23#include "mir/time/clock.h"
24#include <memory>24#include <memory>
25#include <mutex>25#include <mutex>
26#include <unordered_map>26#include <unordered_map>
@@ -37,7 +37,7 @@
37{37{
38public:38public:
39 CompositorReport(std::shared_ptr<Logger> const& logger,39 CompositorReport(std::shared_ptr<Logger> const& logger,
40 std::shared_ptr<time::TimeSource> const& clock);40 std::shared_ptr<time::Clock> const& clock);
41 void added_display(int width, int height, int x, int y, SubCompositorId id);41 void added_display(int width, int height, int x, int y, SubCompositorId id);
42 void began_frame(SubCompositorId id);42 void began_frame(SubCompositorId id);
43 void finished_frame(SubCompositorId id);43 void finished_frame(SubCompositorId id);
@@ -47,7 +47,7 @@
4747
48private:48private:
49 std::shared_ptr<Logger> const logger;49 std::shared_ptr<Logger> const logger;
50 std::shared_ptr<time::TimeSource> const clock;50 std::shared_ptr<time::Clock> const clock;
5151
52 typedef time::Timestamp TimePoint;52 typedef time::Timestamp TimePoint;
53 TimePoint now() const;53 TimePoint now() const;
5454
=== modified file 'src/server/logging/default_configuration.cpp'
--- src/server/logging/default_configuration.cpp 2013-12-24 06:16:59 +0000
+++ src/server/logging/default_configuration.cpp 2014-01-06 02:59:24 +0000
@@ -81,7 +81,7 @@
81 if (the_options()->get(compositor_report_opt, off_opt_value) == log_opt_value)81 if (the_options()->get(compositor_report_opt, off_opt_value) == log_opt_value)
82 {82 {
83 return std::make_shared<ml::CompositorReport>(83 return std::make_shared<ml::CompositorReport>(
84 the_logger(), the_time_source());84 the_logger(), the_clock());
85 }85 }
86 else86 else
87 {87 {
8888
=== modified file 'src/server/logging/message_processor_report.cpp'
--- src/server/logging/message_processor_report.cpp 2013-12-12 08:34:23 +0000
+++ src/server/logging/message_processor_report.cpp 2014-01-06 02:59:24 +0000
@@ -32,9 +32,9 @@
3232
33ml::MessageProcessorReport::MessageProcessorReport(33ml::MessageProcessorReport::MessageProcessorReport(
34 std::shared_ptr<Logger> const& log,34 std::shared_ptr<Logger> const& log,
35 std::shared_ptr<time::TimeSource> const& time_source) :35 std::shared_ptr<time::Clock> const& clock) :
36 log(log),36 log(log),
37 time_source(time_source)37 clock(clock)
38{38{
39}39}
4040
@@ -79,13 +79,13 @@
79 auto& invocations = mediators[mediator].current_invocations;79 auto& invocations = mediators[mediator].current_invocations;
80 auto& invocation = invocations[id];80 auto& invocation = invocations[id];
8181
82 invocation.start = time_source->sample();82 invocation.start = clock->sample();
83 invocation.method = method;83 invocation.method = method;
84}84}
8585
86void ml::MessageProcessorReport::completed_invocation(void const* mediator, int id, bool result)86void ml::MessageProcessorReport::completed_invocation(void const* mediator, int id, bool result)
87{87{
88 auto const end = time_source->sample();88 auto const end = clock->sample();
89 std::ostringstream out;89 std::ostringstream out;
9090
91 {91 {
9292
=== modified file 'tests/unit-tests/logging/message_processor_report.cpp'
--- tests/unit-tests/logging/message_processor_report.cpp 2013-03-28 14:20:06 +0000
+++ tests/unit-tests/logging/message_processor_report.cpp 2014-01-06 02:59:24 +0000
@@ -28,12 +28,12 @@
2828
29namespace29namespace
30{30{
31class MockTimeSource : public mir::time::TimeSource31class MockClock : public mir::time::Clock
32{32{
33public:33public:
34 MOCK_CONST_METHOD0(sample, mir::time::Timestamp());34 MOCK_CONST_METHOD0(sample, mir::time::Timestamp());
3535
36 ~MockTimeSource() noexcept(true) {}36 ~MockClock() noexcept(true) {}
37};37};
3838
39class MockLogger : public mir::logging::Logger39class MockLogger : public mir::logging::Logger
@@ -45,13 +45,13 @@
4545
46struct MessageProcessorReport : public Test46struct MessageProcessorReport : public Test
47{47{
48 MockLogger logger;48 MockLogger logger;
49 MockTimeSource time_source;49 MockClock clock;
5050
51 mir::logging::MessageProcessorReport report;51 mir::logging::MessageProcessorReport report;
5252
53 MessageProcessorReport() :53 MessageProcessorReport() :
54 report(mir::test::fake_shared(logger), mir::test::fake_shared(time_source))54 report(mir::test::fake_shared(logger), mir::test::fake_shared(clock))
55 {55 {
56 EXPECT_CALL(logger, log(56 EXPECT_CALL(logger, log(
57 mir::logging::Logger::debug,57 mir::logging::Logger::debug,
@@ -64,7 +64,7 @@
64TEST_F(MessageProcessorReport, everything_fine)64TEST_F(MessageProcessorReport, everything_fine)
65{65{
66 mir::time::Timestamp a_time;66 mir::time::Timestamp a_time;
67 EXPECT_CALL(time_source, sample()).Times(2).WillRepeatedly(Return(a_time));67 EXPECT_CALL(clock, sample()).Times(2).WillRepeatedly(Return(a_time));
68 EXPECT_CALL(logger, log(68 EXPECT_CALL(logger, log(
69 mir::logging::Logger::informational,69 mir::logging::Logger::informational,
70 EndsWith(": a_function(), elapsed=0µs"),70 EndsWith(": a_function(), elapsed=0µs"),
@@ -79,7 +79,7 @@
79 mir::time::Timestamp a_time;79 mir::time::Timestamp a_time;
80 mir::time::Timestamp another_time = a_time + std::chrono::microseconds(1234);80 mir::time::Timestamp another_time = a_time + std::chrono::microseconds(1234);
8181
82 EXPECT_CALL(time_source, sample()).Times(2)82 EXPECT_CALL(clock, sample()).Times(2)
83 .WillOnce(Return(a_time)).WillOnce(Return(another_time));83 .WillOnce(Return(a_time)).WillOnce(Return(another_time));
8484
85 EXPECT_CALL(logger, log(85 EXPECT_CALL(logger, log(
@@ -94,7 +94,7 @@
94TEST_F(MessageProcessorReport, reports_disconnect)94TEST_F(MessageProcessorReport, reports_disconnect)
95{95{
96 mir::time::Timestamp a_time;96 mir::time::Timestamp a_time;
97 EXPECT_CALL(time_source, sample()).Times(2).WillRepeatedly(Return(a_time));97 EXPECT_CALL(clock, sample()).Times(2).WillRepeatedly(Return(a_time));
98 EXPECT_CALL(logger, log(98 EXPECT_CALL(logger, log(
99 mir::logging::Logger::informational,99 mir::logging::Logger::informational,
100 HasSubstr("(disconnecting)"),100 HasSubstr("(disconnecting)"),
@@ -109,7 +109,7 @@
109 const char* testError = "***Test error***";109 const char* testError = "***Test error***";
110110
111 mir::time::Timestamp a_time;111 mir::time::Timestamp a_time;
112 EXPECT_CALL(time_source, sample()).Times(2).WillRepeatedly(Return(a_time));112 EXPECT_CALL(clock, sample()).Times(2).WillRepeatedly(Return(a_time));
113 EXPECT_CALL(logger, log(113 EXPECT_CALL(logger, log(
114 mir::logging::Logger::informational,114 mir::logging::Logger::informational,
115 HasSubstr(testError),115 HasSubstr(testError),
@@ -122,7 +122,7 @@
122122
123TEST_F(MessageProcessorReport, reports_unknown_method)123TEST_F(MessageProcessorReport, reports_unknown_method)
124{124{
125 EXPECT_CALL(time_source, sample()).Times(0);125 EXPECT_CALL(clock, sample()).Times(0);
126 EXPECT_CALL(logger, log(126 EXPECT_CALL(logger, log(
127 mir::logging::Logger::warning,127 mir::logging::Logger::warning,
128 HasSubstr("UNKNOWN method=\"unknown_function_name\""),128 HasSubstr("UNKNOWN method=\"unknown_function_name\""),
@@ -146,7 +146,7 @@
146TEST_F(MessageProcessorReport, logs_a_debug_message_when_invocation_starts)146TEST_F(MessageProcessorReport, logs_a_debug_message_when_invocation_starts)
147{147{
148 mir::time::Timestamp a_time;148 mir::time::Timestamp a_time;
149 EXPECT_CALL(time_source, sample()).Times(AnyNumber()).WillRepeatedly(Return(a_time));149 EXPECT_CALL(clock, sample()).Times(AnyNumber()).WillRepeatedly(Return(a_time));
150 EXPECT_CALL(logger, log(150 EXPECT_CALL(logger, log(
151 mir::logging::Logger::informational,151 mir::logging::Logger::informational,
152 HasSubstr("Calls outstanding on exit:"),152 HasSubstr("Calls outstanding on exit:"),
@@ -163,7 +163,7 @@
163TEST_F(MessageProcessorReport, logs_incomplete_calls_on_destruction)163TEST_F(MessageProcessorReport, logs_incomplete_calls_on_destruction)
164{164{
165 mir::time::Timestamp a_time;165 mir::time::Timestamp a_time;
166 EXPECT_CALL(time_source, sample()).Times(AnyNumber()).WillRepeatedly(Return(a_time));166 EXPECT_CALL(clock, sample()).Times(AnyNumber()).WillRepeatedly(Return(a_time));
167167
168 EXPECT_CALL(logger, log(168 EXPECT_CALL(logger, log(
169 mir::logging::Logger::informational,169 mir::logging::Logger::informational,
170170
=== modified file 'tests/unit-tests/logging/test_compositor_report.cpp'
--- tests/unit-tests/logging/test_compositor_report.cpp 2013-12-24 08:07:27 +0000
+++ tests/unit-tests/logging/test_compositor_report.cpp 2014-01-06 02:59:24 +0000
@@ -28,7 +28,7 @@
28namespace28namespace
29{29{
3030
31class FakeClock : public time::TimeSource31class FakeClock : public time::Clock
32{32{
33public:33public:
34 void elapse(chrono::microseconds delta)34 void elapse(chrono::microseconds delta)

Subscribers

People subscribed via source and target branches