[Groonga-commit] groonga/grnxx [master] Disable to omit the argument of grnxx::Stopwatch::Stopwatch().

Back to archive index

susumu.yata null+****@clear*****
Thu Feb 28 14:18:11 JST 2013


susumu.yata	2013-02-28 14:18:11 +0900 (Thu, 28 Feb 2013)

  New Revision: 779dd72943b0e92d405991dbe18db81061787778
  https://github.com/groonga/grnxx/commit/779dd72943b0e92d405991dbe18db81061787778

  Log:
    Disable to omit the argument of grnxx::Stopwatch::Stopwatch().

  Modified files:
    lib/mutex.cpp
    lib/stopwatch.hpp
    test/test_stopwatch.cpp

  Modified: lib/mutex.cpp (+1 -1)
===================================================================
--- lib/mutex.cpp    2013-02-28 14:01:05 +0900 (32c6711)
+++ lib/mutex.cpp    2013-02-28 14:18:11 +0900 (e3e8038)
@@ -53,7 +53,7 @@ bool Mutex::lock_with_timeout(Duration timeout) {
   }
 
   const bool has_deadline = timeout >= Duration(0);
-  Stopwatch stopwatch;
+  Stopwatch stopwatch(false);
   if (has_deadline) {
     stopwatch.start();
   }

  Modified: lib/stopwatch.hpp (+5 -1)
===================================================================
--- lib/stopwatch.hpp    2013-02-28 14:01:05 +0900 (4f35c51)
+++ lib/stopwatch.hpp    2013-02-28 14:18:11 +0900 (bbb57ac)
@@ -30,8 +30,12 @@ enum {
 // To measure the amount of time elapsed.
 class Stopwatch {
  public:
+  // Disable the default constructor so that users don't forget to start a
+  // stopwatch.
+  Stopwatch() = delete;
+
   // Construct a stopwatch, which is started if is_running == true.
-  explicit Stopwatch(bool is_running = false)
+  explicit Stopwatch(bool is_running)
     : elapsed_(0),
       start_time_(),
       is_running_(is_running) {

  Modified: test/test_stopwatch.cpp (+1 -1)
===================================================================
--- test/test_stopwatch.cpp    2013-02-28 14:01:05 +0900 (7b226a5)
+++ test/test_stopwatch.cpp    2013-02-28 14:18:11 +0900 (170f145)
@@ -26,7 +26,7 @@ int main() {
                            grnxx::LOGGER_ENABLE_COUT);
   grnxx::Logger::set_max_level(grnxx::NOTICE_LOGGER);
 
-  grnxx::Stopwatch stopwatch;
+  grnxx::Stopwatch stopwatch(false);
   assert(stopwatch.elapsed() == grnxx::Duration(0));
 
   stopwatch.start();
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-commit mailing list
Back to archive index