[{"id":22365,"web_url":"https://patchwork.libcamera.org/comment/22365/","msgid":"<164798935424.506124.5289342867167838003@Monstersaurus>","date":"2022-03-22T22:49:14","subject":"Re: [libcamera-devel] [PATCH] libcamera: base: timer: Drop start()\n\toverload with int argument","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nQuoting Laurent Pinchart via libcamera-devel (2022-03-22 20:42:48)\n> The start(unsigned int msec) overload is error-prone, as the argument\n> unit can easily be mistaken in callers. Drop it and update all callers\n> to use the start(std::chrono::milliseconds) overload instead.\n> \n> The callers now need to use std::chrono_literals. The using statement\n> could be added to timer.h for convenience, but \"using\" is discouraged in\n> header files to avoid namespace pollution. Update the callers instead,\n> and while at it, sort the \"using\" statements alphabetically in tests.\n> \n\nDoes a utils::Duration implicitly get cast/converted to a\nstd::chrono::milliseconds() with this now?\n\nI.e. - does this help ease Naush's patches to accept a utils::duration?\n(Which is a good-thing-tm I think)\n\nAnyway, I have a lot of fondness for chrono-literals. I think they\nreally help improve readability, and I expect prevent bugs.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/base/timer.h           |  1 -\n>  src/libcamera/base/timer.cpp             | 10 --------\n>  src/libcamera/ipc_pipe_unixsocket.cpp    |  4 ++-\n>  test/camera/buffer_import.cpp            |  3 ++-\n>  test/camera/camera_reconfigure.cpp       |  3 ++-\n>  test/camera/capture.cpp                  |  3 ++-\n>  test/event-dispatcher.cpp                |  9 ++++---\n>  test/event.cpp                           | 11 +++++----\n>  test/fence.cpp                           |  6 ++---\n>  test/hotplug-cameras.cpp                 |  5 ++--\n>  test/ipa/ipa_interface_test.cpp          |  9 ++++---\n>  test/ipc/unixsocket.cpp                  |  5 ++--\n>  test/log/log_process.cpp                 |  5 ++--\n>  test/process/process_test.cpp            |  5 ++--\n>  test/timer-thread.cpp                    |  7 +++---\n>  test/timer.cpp                           | 31 ++++++++++++------------\n>  test/v4l2_videodevice/buffer_sharing.cpp |  3 ++-\n>  test/v4l2_videodevice/capture_async.cpp  |  3 ++-\n>  test/v4l2_videodevice/v4l2_m2mdevice.cpp |  5 ++--\n>  19 files changed, 67 insertions(+), 61 deletions(-)\n> \n> diff --git a/include/libcamera/base/timer.h b/include/libcamera/base/timer.h\n> index 09f1d3229bd5..759b68ada1e8 100644\n> --- a/include/libcamera/base/timer.h\n> +++ b/include/libcamera/base/timer.h\n> @@ -25,7 +25,6 @@ public:\n>         Timer(Object *parent = nullptr);\n>         ~Timer();\n>  \t\n> -       void start(unsigned int msec) { start(std::chrono::milliseconds(msec)); }\n>         void start(std::chrono::milliseconds duration);\n>         void start(std::chrono::steady_clock::time_point deadline);\n>         void stop();\n> diff --git a/src/libcamera/base/timer.cpp b/src/libcamera/base/timer.cpp\n> index 187336e3a1a4..74b060af32ff 100644\n> --- a/src/libcamera/base/timer.cpp\n> +++ b/src/libcamera/base/timer.cpp\n> @@ -62,16 +62,6 @@ Timer::~Timer()\n>         stop();\n>  }\n>  \n> -/**\n> - * \\fn Timer::start(unsigned int msec)\n> - * \\brief Start or restart the timer with a timeout of \\a msec\n> - * \\param[in] msec The timer duration in milliseconds\n> - *\n> - * If the timer is already running it will be stopped and restarted.\n> - *\n> - * \\context This function is \\threadbound.\n> - */\n> -\n>  /**\n>   * \\brief Start or restart the timer with a timeout of \\a duration\n>   * \\param[in] duration The timer duration in milliseconds\n> diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp\n> index 3ef907090131..da2cffc3b149 100644\n> --- a/src/libcamera/ipc_pipe_unixsocket.cpp\n> +++ b/src/libcamera/ipc_pipe_unixsocket.cpp\n> @@ -18,6 +18,8 @@\n>  #include \"libcamera/internal/ipc_unixsocket.h\"\n>  #include \"libcamera/internal/process.h\"\n>  \n> +using namespace std::chrono_literals;\n> +\n>  namespace libcamera {\n>  \n>  LOG_DECLARE_CATEGORY(IPCPipe)\n> @@ -126,7 +128,7 @@ int IPCPipeUnixSocket::call(const IPCUnixSocket::Payload &message,\n>         }\n>  \n>         /* \\todo Make this less dangerous, see IPCPipe::sendSync() */\n> -       timeout.start(2000);\n> +       timeout.start(2000ms);\n>         while (!iter->second.done) {\n>                 if (!timeout.isRunning()) {\n>                         LOG(IPCPipe, Error) << \"Call timeout!\";\n> diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\n> index c504ea09e64b..9288400474a7 100644\n> --- a/test/camera/buffer_import.cpp\n> +++ b/test/camera/buffer_import.cpp\n> @@ -25,6 +25,7 @@\n>  #include \"test.h\"\n>  \n>  using namespace libcamera;\n> +using namespace std::chrono_literals;\n>  \n>  namespace {\n>  \n> @@ -135,7 +136,7 @@ protected:\n>                 EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n>  \n>                 Timer timer;\n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>                 while (timer.isRunning())\n>                         dispatcher->processEvents();\n>  \n> diff --git a/test/camera/camera_reconfigure.cpp b/test/camera/camera_reconfigure.cpp\n> index 0fd8ab70d561..f6076baa0a31 100644\n> --- a/test/camera/camera_reconfigure.cpp\n> +++ b/test/camera/camera_reconfigure.cpp\n> @@ -23,6 +23,7 @@\n>  \n>  using namespace libcamera;\n>  using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  namespace {\n>  \n> @@ -117,7 +118,7 @@ private:\n>                 EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n>  \n>                 Timer timer;\n> -               timer.start(100);\n> +               timer.start(100ms);\n>                 while (timer.isRunning())\n>                         dispatcher->processEvents();\n>  \n> diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> index f3824f95cbd3..de824083dfed 100644\n> --- a/test/camera/capture.cpp\n> +++ b/test/camera/capture.cpp\n> @@ -18,6 +18,7 @@\n>  \n>  using namespace libcamera;\n>  using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  namespace {\n>  \n> @@ -137,7 +138,7 @@ protected:\n>                 EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n>  \n>                 Timer timer;\n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>                 while (timer.isRunning())\n>                         dispatcher->processEvents();\n>  \n> diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp\n> index 1cc17b045ec0..9b07ab2b61d7 100644\n> --- a/test/event-dispatcher.cpp\n> +++ b/test/event-dispatcher.cpp\n> @@ -16,8 +16,9 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace std;\n>  using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  static EventDispatcher *dispatcher;\n>  static bool interrupt;\n> @@ -50,7 +51,7 @@ protected:\n>                 /* Event processing interruption by signal. */\n>                 std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();\n>  \n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>  \n>                 struct itimerval itimer = {};\n>                 itimer.it_value.tv_usec = 500000;\n> @@ -69,7 +70,7 @@ protected:\n>                 }\n>  \n>                 /* Event processing interruption. */\n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>                 dispatcher->interrupt();\n>  \n>                 dispatcher->processEvents();\n> @@ -79,7 +80,7 @@ protected:\n>                         return TestFail;\n>                 }\n>  \n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>                 itimer.it_value.tv_usec = 500000;\n>                 interrupt = true;\n>                 setitimer(ITIMER_REAL, &itimer, nullptr);\n> diff --git a/test/event.cpp b/test/event.cpp\n> index d4765eb14d12..19dceae123dd 100644\n> --- a/test/event.cpp\n> +++ b/test/event.cpp\n> @@ -16,8 +16,9 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace std;\n>  using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  class EventTest : public Test\n>  {\n> @@ -55,7 +56,7 @@ protected:\n>                         return TestFail;\n>                 }\n>  \n> -               timeout.start(100);\n> +               timeout.start(100ms);\n>                 dispatcher->processEvents();\n>                 timeout.stop();\n>  \n> @@ -67,7 +68,7 @@ protected:\n>                 /* Test read notification without data. */\n>                 notified_ = false;\n>  \n> -               timeout.start(100);\n> +               timeout.start(100ms);\n>                 dispatcher->processEvents();\n>                 timeout.stop();\n>  \n> @@ -86,7 +87,7 @@ protected:\n>                         return TestFail;\n>                 }\n>  \n> -               timeout.start(100);\n> +               timeout.start(100ms);\n>                 dispatcher->processEvents();\n>                 timeout.stop();\n>  \n> @@ -99,7 +100,7 @@ protected:\n>                 notified_ = false;\n>                 notifier_->setEnabled(true);\n>  \n> -               timeout.start(100);\n> +               timeout.start(100ms);\n>                 dispatcher->processEvents();\n>                 timeout.stop();\n>  \n> diff --git a/test/fence.cpp b/test/fence.cpp\n> index 524db2a10757..1e38bc2f8790 100644\n> --- a/test/fence.cpp\n> +++ b/test/fence.cpp\n> @@ -22,9 +22,9 @@\n>  #include \"camera_test.h\"\n>  #include \"test.h\"\n>  \n> -using namespace std::chrono_literals;\n>  using namespace libcamera;\n>  using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  class FenceTest : public CameraTest, public Test\n>  {\n> @@ -316,7 +316,7 @@ int FenceTest::run()\n>  \n>         /* Loop for one second. */\n>         Timer timer;\n> -       timer.start(1000);\n> +       timer.start(1000ms);\n>         while (timer.isRunning() && expectedCompletionResult_) {\n>                 if (completedRequest_ == signalledRequestId_ && setFence_)\n>                         /*\n> @@ -324,7 +324,7 @@ int FenceTest::run()\n>                          * been re-queued with a fence. Start the timer to\n>                          * signal the fence in 10 msec.\n>                          */\n> -                       fenceTimer.start(10);\n> +                       fenceTimer.start(10ms);\n>  \n>                 dispatcher_->processEvents();\n>         }\n> diff --git a/test/hotplug-cameras.cpp b/test/hotplug-cameras.cpp\n> index df56040350c5..5d9260a241ec 100644\n> --- a/test/hotplug-cameras.cpp\n> +++ b/test/hotplug-cameras.cpp\n> @@ -22,6 +22,7 @@\n>  #include \"test.h\"\n>  \n>  using namespace libcamera;\n> +using namespace std::chrono_literals;\n>  \n>  class HotplugTest : public Test\n>  {\n> @@ -88,7 +89,7 @@ protected:\n>                 std::ofstream(uvcDriverDir_ + \"unbind\", std::ios::binary)\n>                         << uvcDeviceDir;\n>                 Timer timer;\n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>                 while (timer.isRunning() && !cameraRemoved_)\n>                         Thread::current()->eventDispatcher()->processEvents();\n>                 if (!cameraRemoved_) {\n> @@ -99,7 +100,7 @@ protected:\n>                 /* Bind the camera again and process events. */\n>                 std::ofstream(uvcDriverDir_ + \"bind\", std::ios::binary)\n>                         << uvcDeviceDir;\n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>                 while (timer.isRunning() && !cameraAdded_)\n>                         Thread::current()->eventDispatcher()->processEvents();\n>                 if (!cameraAdded_) {\n> diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\n> index 43562e608506..3c0df843ea61 100644\n> --- a/test/ipa/ipa_interface_test.cpp\n> +++ b/test/ipa/ipa_interface_test.cpp\n> @@ -27,8 +27,9 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace std;\n>  using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  class IPAInterfaceTest : public Test, public Object\n>  {\n> @@ -111,7 +112,7 @@ protected:\n>                         return TestFail;\n>                 }\n>  \n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>                 while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationInit)\n>                         dispatcher->processEvents();\n>  \n> @@ -123,7 +124,7 @@ protected:\n>  \n>                 /* Test start of IPA module. */\n>                 ipa_->start();\n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>                 while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationStart)\n>                         dispatcher->processEvents();\n>  \n> @@ -134,7 +135,7 @@ protected:\n>  \n>                 /* Test stop of IPA module. */\n>                 ipa_->stop();\n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>                 while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationStop)\n>                         dispatcher->processEvents();\n>  \n> diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp\n> index 7e90e629e9ac..304e613bc984 100644\n> --- a/test/ipc/unixsocket.cpp\n> +++ b/test/ipc/unixsocket.cpp\n> @@ -30,8 +30,9 @@\n>  #define CMD_LEN_CMP    3\n>  #define CMD_JOIN       4\n>  \n> -using namespace std;\n>  using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  int calculateLength(int fd)\n>  {\n> @@ -430,7 +431,7 @@ private:\n>                 if (ret)\n>                         return ret;\n>  \n> -               timeout.start(200);\n> +               timeout.start(200ms);\n>                 while (!callDone_) {\n>                         if (!timeout.isRunning()) {\n>                                 cerr << \"Call timeout!\" << endl;\n> diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp\n> index 2484c58f2fa9..966b80cf3af7 100644\n> --- a/test/log/log_process.cpp\n> +++ b/test/log/log_process.cpp\n> @@ -26,8 +26,9 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace std;\n>  using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  static const string message(\"hello from the child\");\n>  \n> @@ -80,7 +81,7 @@ protected:\n>                         return TestFail;\n>                 }\n>  \n> -               timeout.start(200);\n> +               timeout.start(200ms);\n>                 while (timeout.isRunning())\n>                         dispatcher->processEvents();\n>  \n> diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp\n> index b410756b3288..cb6940c6a7db 100644\n> --- a/test/process/process_test.cpp\n> +++ b/test/process/process_test.cpp\n> @@ -18,8 +18,9 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace std;\n>  using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  class ProcessTestChild\n>  {\n> @@ -61,7 +62,7 @@ protected:\n>                         return TestFail;\n>                 }\n>  \n> -               timeout.start(2000);\n> +               timeout.start(2000ms);\n>                 while (timeout.isRunning() && exitStatus_ == Process::NotExited)\n>                         dispatcher->processEvents();\n>  \n> diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp\n> index f7e8743da9e6..618217538779 100644\n> --- a/test/timer-thread.cpp\n> +++ b/test/timer-thread.cpp\n> @@ -14,8 +14,9 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace std;\n>  using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  class TimeoutHandler : public Object\n>  {\n> @@ -24,13 +25,13 @@ public:\n>                 : timer_(this), timeout_(false)\n>         {\n>                 timer_.timeout.connect(this, &TimeoutHandler::timeoutHandler);\n> -               timer_.start(100);\n> +               timer_.start(100ms);\n>         }\n>  \n>         void restart()\n>         {\n>                 timeout_ = false;\n> -               timer_.start(100);\n> +               timer_.start(100ms);\n>         }\n>  \n>         bool timeout() const\n> diff --git a/test/timer.cpp b/test/timer.cpp\n> index be79d0100a58..0f01c3cb00ea 100644\n> --- a/test/timer.cpp\n> +++ b/test/timer.cpp\n> @@ -14,8 +14,9 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace std;\n>  using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  class ManagedTimer : public Timer\n>  {\n> @@ -26,7 +27,7 @@ public:\n>                 timeout.connect(this, &ManagedTimer::timeoutHandler);\n>         }\n>  \n> -       void start(int msec)\n> +       void start(std::chrono::milliseconds msec)\n>         {\n>                 count_ = 0;\n>                 start_ = std::chrono::steady_clock::now();\n> @@ -82,7 +83,7 @@ protected:\n>                 ManagedTimer timer2;\n>  \n>                 /* Timer expiration. */\n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>  \n>                 if (!timer.isRunning()) {\n>                         cout << \"Timer expiration test failed\" << endl;\n> @@ -101,7 +102,7 @@ protected:\n>                  * Nanosecond resolution in a 32 bit value wraps at 4.294967\n>                  * seconds (0xFFFFFFFF / 1000000)\n>                  */\n> -               timer.start(4295);\n> +               timer.start(4295ms);\n>                 dispatcher->processEvents();\n>  \n>                 if (timer.hasFailed()) {\n> @@ -110,7 +111,7 @@ protected:\n>                 }\n>  \n>                 /* Timer restart. */\n> -               timer.start(500);\n> +               timer.start(500ms);\n>  \n>                 if (!timer.isRunning()) {\n>                         cout << \"Timer restart test failed\" << endl;\n> @@ -125,9 +126,9 @@ protected:\n>                 }\n>  \n>                 /* Timer restart before expiration. */\n> -               timer.start(50);\n> -               timer.start(100);\n> -               timer.start(150);\n> +               timer.start(50ms);\n> +               timer.start(100ms);\n> +               timer.start(150ms);\n>  \n>                 dispatcher->processEvents();\n>  \n> @@ -147,8 +148,8 @@ protected:\n>                 }\n>  \n>                 /* Two timers. */\n> -               timer.start(1000);\n> -               timer2.start(300);\n> +               timer.start(1000ms);\n> +               timer2.start(300ms);\n>  \n>                 dispatcher->processEvents();\n>  \n> @@ -170,8 +171,8 @@ protected:\n>                 }\n>  \n>                 /* Restart timer before expiration. */\n> -               timer.start(1000);\n> -               timer2.start(300);\n> +               timer.start(1000ms);\n> +               timer2.start(300ms);\n>  \n>                 dispatcher->processEvents();\n>  \n> @@ -180,7 +181,7 @@ protected:\n>                         return TestFail;\n>                 }\n>  \n> -               timer.start(1000);\n> +               timer.start(1000ms);\n>  \n>                 dispatcher->processEvents();\n>  \n> @@ -194,10 +195,10 @@ protected:\n>                  * deleted. This will result in a crash on failure.\n>                  */\n>                 ManagedTimer *dyntimer = new ManagedTimer();\n> -               dyntimer->start(100);\n> +               dyntimer->start(100ms);\n>                 delete dyntimer;\n>  \n> -               timer.start(200);\n> +               timer.start(200ms);\n>                 dispatcher->processEvents();\n>  \n>                 return TestPass;\n> diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp\n> index 75ee93ce5261..fa856ab6b5a8 100644\n> --- a/test/v4l2_videodevice/buffer_sharing.cpp\n> +++ b/test/v4l2_videodevice/buffer_sharing.cpp\n> @@ -21,6 +21,7 @@\n>  #include \"v4l2_videodevice_test.h\"\n>  \n>  using namespace libcamera;\n> +using namespace std::chrono_literals;\n>  \n>  class BufferSharingTest : public V4L2VideoDeviceTest\n>  {\n> @@ -145,7 +146,7 @@ protected:\n>                         return TestFail;\n>                 }\n>  \n> -               timeout.start(10000);\n> +               timeout.start(10000ms);\n>                 while (timeout.isRunning()) {\n>                         dispatcher->processEvents();\n>                         if (framesCaptured_ > 30 && framesOutput_ > 30)\n> diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp\n> index 3aa4ca0b6955..42e1e671790b 100644\n> --- a/test/v4l2_videodevice/capture_async.cpp\n> +++ b/test/v4l2_videodevice/capture_async.cpp\n> @@ -16,6 +16,7 @@\n>  #include \"v4l2_videodevice_test.h\"\n>  \n>  using namespace libcamera;\n> +using namespace std::chrono_literals;\n>  \n>  class CaptureAsyncTest : public V4L2VideoDeviceTest\n>  {\n> @@ -60,7 +61,7 @@ protected:\n>                 if (ret)\n>                         return TestFail;\n>  \n> -               timeout.start(10000);\n> +               timeout.start(10000ms);\n>                 while (timeout.isRunning()) {\n>                         dispatcher->processEvents();\n>                         if (frames > 30)\n> diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> index ebf3e245f86b..852b853fa81a 100644\n> --- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> +++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> @@ -19,8 +19,9 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace std;\n>  using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>  \n>  class V4L2M2MDeviceTest : public Test\n>  {\n> @@ -155,7 +156,7 @@ protected:\n>                 }\n>  \n>                 Timer timeout;\n> -               timeout.start(5000);\n> +               timeout.start(5000ms);\n>                 while (timeout.isRunning()) {\n>                         dispatcher->processEvents();\n>                         if (captureFrames_ > 30)\n> \n> base-commit: a8284e3570de133960458c5703e75dc9e8e737c8\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0FC0FC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Mar 2022 22:49:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 662A3604E6;\n\tTue, 22 Mar 2022 23:49:18 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D1443604C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Mar 2022 23:49:16 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6ED83DFA;\n\tTue, 22 Mar 2022 23:49:16 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647989358;\n\tbh=03FyD4V3jwBzOW3Fpcnj3SnwiW1lpXEUAd5rSiPb/+M=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=3f92swuJ82oXLVYCgh01LOvKiUVVfUsIaUilQOvehSG8OI6eJP481itI4LlNjtjUu\n\tqHC42fXyM5H6Gvxzi33ZWSZ+9K9tinIHq4RXvOVUvDLEBjsDwy8PNqi9hznwvj7gyi\n\tiobhPJf+zh/PKIgnIXd8yJsnXPP68kKtMbs+RD16Nocm9ZSz7gMNU/f3b9XCfRQJEr\n\tDG2hqnMq0jJqFJpIzhypepSiUH+SoM0WeMze6cvDXFVH5wYdXMp5kPpq+tce7md6mv\n\toN1b9HxD87bsOo9zeKJcleZuHXIK3KoQrNjmp+lvlVFffjFHjCT604iGXCBmzHa3vn\n\tQ2GqZSYp6aXmg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1647989356;\n\tbh=03FyD4V3jwBzOW3Fpcnj3SnwiW1lpXEUAd5rSiPb/+M=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=hEd6CMuDKGexYzI34T7j/ovJJCDVbnpNDGAwLPloxuY6oEBQFuXiO+/pZszjW+L1Z\n\tDU5wZHE77iILqcfacGtjTJy0i3uyz3q1y0mi9+a23ul1HDwJ4LmpokaMxed+P1Pds1\n\tpA/tYLouGkC3+99aIywBKJe7J3u1x3SK0793cSOE="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"hEd6CMuD\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220322204248.9226-1-laurent.pinchart@ideasonboard.com>","References":"<20220322204248.9226-1-laurent.pinchart@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 22 Mar 2022 22:49:14 +0000","Message-ID":"<164798935424.506124.5289342867167838003@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] libcamera: base: timer: Drop start()\n\toverload with int argument","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22378,"web_url":"https://patchwork.libcamera.org/comment/22378/","msgid":"<YjpxrOhPCym85SiY@pendragon.ideasonboard.com>","date":"2022-03-23T01:02:36","subject":"Re: [libcamera-devel] [PATCH] libcamera: base: timer: Drop start()\n\toverload with int argument","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Tue, Mar 22, 2022 at 10:49:14PM +0000, Kieran Bingham wrote:\n> Hi Laurent,\n> \n> Quoting Laurent Pinchart via libcamera-devel (2022-03-22 20:42:48)\n> > The start(unsigned int msec) overload is error-prone, as the argument\n> > unit can easily be mistaken in callers. Drop it and update all callers\n> > to use the start(std::chrono::milliseconds) overload instead.\n> > \n> > The callers now need to use std::chrono_literals. The using statement\n> > could be added to timer.h for convenience, but \"using\" is discouraged in\n> > header files to avoid namespace pollution. Update the callers instead,\n> > and while at it, sort the \"using\" statements alphabetically in tests.\n> \n> Does a utils::Duration implicitly get cast/converted to a\n> std::chrono::milliseconds() with this now?\n> \n> I.e. - does this help ease Naush's patches to accept a utils::duration?\n> (Which is a good-thing-tm I think)\n\nNot to my knowledge, no. I was inspired by Naush's patch, but didn't\nmake an attempt at addressing the same issue.\n\n> Anyway, I have a lot of fondness for chrono-literals. I think they\n> really help improve readability, and I expect prevent bugs.\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  include/libcamera/base/timer.h           |  1 -\n> >  src/libcamera/base/timer.cpp             | 10 --------\n> >  src/libcamera/ipc_pipe_unixsocket.cpp    |  4 ++-\n> >  test/camera/buffer_import.cpp            |  3 ++-\n> >  test/camera/camera_reconfigure.cpp       |  3 ++-\n> >  test/camera/capture.cpp                  |  3 ++-\n> >  test/event-dispatcher.cpp                |  9 ++++---\n> >  test/event.cpp                           | 11 +++++----\n> >  test/fence.cpp                           |  6 ++---\n> >  test/hotplug-cameras.cpp                 |  5 ++--\n> >  test/ipa/ipa_interface_test.cpp          |  9 ++++---\n> >  test/ipc/unixsocket.cpp                  |  5 ++--\n> >  test/log/log_process.cpp                 |  5 ++--\n> >  test/process/process_test.cpp            |  5 ++--\n> >  test/timer-thread.cpp                    |  7 +++---\n> >  test/timer.cpp                           | 31 ++++++++++++------------\n> >  test/v4l2_videodevice/buffer_sharing.cpp |  3 ++-\n> >  test/v4l2_videodevice/capture_async.cpp  |  3 ++-\n> >  test/v4l2_videodevice/v4l2_m2mdevice.cpp |  5 ++--\n> >  19 files changed, 67 insertions(+), 61 deletions(-)\n> > \n> > diff --git a/include/libcamera/base/timer.h b/include/libcamera/base/timer.h\n> > index 09f1d3229bd5..759b68ada1e8 100644\n> > --- a/include/libcamera/base/timer.h\n> > +++ b/include/libcamera/base/timer.h\n> > @@ -25,7 +25,6 @@ public:\n> >         Timer(Object *parent = nullptr);\n> >         ~Timer();\n> >  \t\n> > -       void start(unsigned int msec) { start(std::chrono::milliseconds(msec)); }\n> >         void start(std::chrono::milliseconds duration);\n> >         void start(std::chrono::steady_clock::time_point deadline);\n> >         void stop();\n> > diff --git a/src/libcamera/base/timer.cpp b/src/libcamera/base/timer.cpp\n> > index 187336e3a1a4..74b060af32ff 100644\n> > --- a/src/libcamera/base/timer.cpp\n> > +++ b/src/libcamera/base/timer.cpp\n> > @@ -62,16 +62,6 @@ Timer::~Timer()\n> >         stop();\n> >  }\n> >  \n> > -/**\n> > - * \\fn Timer::start(unsigned int msec)\n> > - * \\brief Start or restart the timer with a timeout of \\a msec\n> > - * \\param[in] msec The timer duration in milliseconds\n> > - *\n> > - * If the timer is already running it will be stopped and restarted.\n> > - *\n> > - * \\context This function is \\threadbound.\n> > - */\n> > -\n> >  /**\n> >   * \\brief Start or restart the timer with a timeout of \\a duration\n> >   * \\param[in] duration The timer duration in milliseconds\n> > diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp\n> > index 3ef907090131..da2cffc3b149 100644\n> > --- a/src/libcamera/ipc_pipe_unixsocket.cpp\n> > +++ b/src/libcamera/ipc_pipe_unixsocket.cpp\n> > @@ -18,6 +18,8 @@\n> >  #include \"libcamera/internal/ipc_unixsocket.h\"\n> >  #include \"libcamera/internal/process.h\"\n> >  \n> > +using namespace std::chrono_literals;\n> > +\n> >  namespace libcamera {\n> >  \n> >  LOG_DECLARE_CATEGORY(IPCPipe)\n> > @@ -126,7 +128,7 @@ int IPCPipeUnixSocket::call(const IPCUnixSocket::Payload &message,\n> >         }\n> >  \n> >         /* \\todo Make this less dangerous, see IPCPipe::sendSync() */\n> > -       timeout.start(2000);\n> > +       timeout.start(2000ms);\n> >         while (!iter->second.done) {\n> >                 if (!timeout.isRunning()) {\n> >                         LOG(IPCPipe, Error) << \"Call timeout!\";\n> > diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\n> > index c504ea09e64b..9288400474a7 100644\n> > --- a/test/camera/buffer_import.cpp\n> > +++ b/test/camera/buffer_import.cpp\n> > @@ -25,6 +25,7 @@\n> >  #include \"test.h\"\n> >  \n> >  using namespace libcamera;\n> > +using namespace std::chrono_literals;\n> >  \n> >  namespace {\n> >  \n> > @@ -135,7 +136,7 @@ protected:\n> >                 EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n> >  \n> >                 Timer timer;\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning())\n> >                         dispatcher->processEvents();\n> >  \n> > diff --git a/test/camera/camera_reconfigure.cpp b/test/camera/camera_reconfigure.cpp\n> > index 0fd8ab70d561..f6076baa0a31 100644\n> > --- a/test/camera/camera_reconfigure.cpp\n> > +++ b/test/camera/camera_reconfigure.cpp\n> > @@ -23,6 +23,7 @@\n> >  \n> >  using namespace libcamera;\n> >  using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  namespace {\n> >  \n> > @@ -117,7 +118,7 @@ private:\n> >                 EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n> >  \n> >                 Timer timer;\n> > -               timer.start(100);\n> > +               timer.start(100ms);\n> >                 while (timer.isRunning())\n> >                         dispatcher->processEvents();\n> >  \n> > diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> > index f3824f95cbd3..de824083dfed 100644\n> > --- a/test/camera/capture.cpp\n> > +++ b/test/camera/capture.cpp\n> > @@ -18,6 +18,7 @@\n> >  \n> >  using namespace libcamera;\n> >  using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  namespace {\n> >  \n> > @@ -137,7 +138,7 @@ protected:\n> >                 EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n> >  \n> >                 Timer timer;\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning())\n> >                         dispatcher->processEvents();\n> >  \n> > diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp\n> > index 1cc17b045ec0..9b07ab2b61d7 100644\n> > --- a/test/event-dispatcher.cpp\n> > +++ b/test/event-dispatcher.cpp\n> > @@ -16,8 +16,9 @@\n> >  \n> >  #include \"test.h\"\n> >  \n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  static EventDispatcher *dispatcher;\n> >  static bool interrupt;\n> > @@ -50,7 +51,7 @@ protected:\n> >                 /* Event processing interruption by signal. */\n> >                 std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();\n> >  \n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >  \n> >                 struct itimerval itimer = {};\n> >                 itimer.it_value.tv_usec = 500000;\n> > @@ -69,7 +70,7 @@ protected:\n> >                 }\n> >  \n> >                 /* Event processing interruption. */\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 dispatcher->interrupt();\n> >  \n> >                 dispatcher->processEvents();\n> > @@ -79,7 +80,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >  \n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 itimer.it_value.tv_usec = 500000;\n> >                 interrupt = true;\n> >                 setitimer(ITIMER_REAL, &itimer, nullptr);\n> > diff --git a/test/event.cpp b/test/event.cpp\n> > index d4765eb14d12..19dceae123dd 100644\n> > --- a/test/event.cpp\n> > +++ b/test/event.cpp\n> > @@ -16,8 +16,9 @@\n> >  \n> >  #include \"test.h\"\n> >  \n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  class EventTest : public Test\n> >  {\n> > @@ -55,7 +56,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >  \n> > -               timeout.start(100);\n> > +               timeout.start(100ms);\n> >                 dispatcher->processEvents();\n> >                 timeout.stop();\n> >  \n> > @@ -67,7 +68,7 @@ protected:\n> >                 /* Test read notification without data. */\n> >                 notified_ = false;\n> >  \n> > -               timeout.start(100);\n> > +               timeout.start(100ms);\n> >                 dispatcher->processEvents();\n> >                 timeout.stop();\n> >  \n> > @@ -86,7 +87,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >  \n> > -               timeout.start(100);\n> > +               timeout.start(100ms);\n> >                 dispatcher->processEvents();\n> >                 timeout.stop();\n> >  \n> > @@ -99,7 +100,7 @@ protected:\n> >                 notified_ = false;\n> >                 notifier_->setEnabled(true);\n> >  \n> > -               timeout.start(100);\n> > +               timeout.start(100ms);\n> >                 dispatcher->processEvents();\n> >                 timeout.stop();\n> >  \n> > diff --git a/test/fence.cpp b/test/fence.cpp\n> > index 524db2a10757..1e38bc2f8790 100644\n> > --- a/test/fence.cpp\n> > +++ b/test/fence.cpp\n> > @@ -22,9 +22,9 @@\n> >  #include \"camera_test.h\"\n> >  #include \"test.h\"\n> >  \n> > -using namespace std::chrono_literals;\n> >  using namespace libcamera;\n> >  using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  class FenceTest : public CameraTest, public Test\n> >  {\n> > @@ -316,7 +316,7 @@ int FenceTest::run()\n> >  \n> >         /* Loop for one second. */\n> >         Timer timer;\n> > -       timer.start(1000);\n> > +       timer.start(1000ms);\n> >         while (timer.isRunning() && expectedCompletionResult_) {\n> >                 if (completedRequest_ == signalledRequestId_ && setFence_)\n> >                         /*\n> > @@ -324,7 +324,7 @@ int FenceTest::run()\n> >                          * been re-queued with a fence. Start the timer to\n> >                          * signal the fence in 10 msec.\n> >                          */\n> > -                       fenceTimer.start(10);\n> > +                       fenceTimer.start(10ms);\n> >  \n> >                 dispatcher_->processEvents();\n> >         }\n> > diff --git a/test/hotplug-cameras.cpp b/test/hotplug-cameras.cpp\n> > index df56040350c5..5d9260a241ec 100644\n> > --- a/test/hotplug-cameras.cpp\n> > +++ b/test/hotplug-cameras.cpp\n> > @@ -22,6 +22,7 @@\n> >  #include \"test.h\"\n> >  \n> >  using namespace libcamera;\n> > +using namespace std::chrono_literals;\n> >  \n> >  class HotplugTest : public Test\n> >  {\n> > @@ -88,7 +89,7 @@ protected:\n> >                 std::ofstream(uvcDriverDir_ + \"unbind\", std::ios::binary)\n> >                         << uvcDeviceDir;\n> >                 Timer timer;\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning() && !cameraRemoved_)\n> >                         Thread::current()->eventDispatcher()->processEvents();\n> >                 if (!cameraRemoved_) {\n> > @@ -99,7 +100,7 @@ protected:\n> >                 /* Bind the camera again and process events. */\n> >                 std::ofstream(uvcDriverDir_ + \"bind\", std::ios::binary)\n> >                         << uvcDeviceDir;\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning() && !cameraAdded_)\n> >                         Thread::current()->eventDispatcher()->processEvents();\n> >                 if (!cameraAdded_) {\n> > diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\n> > index 43562e608506..3c0df843ea61 100644\n> > --- a/test/ipa/ipa_interface_test.cpp\n> > +++ b/test/ipa/ipa_interface_test.cpp\n> > @@ -27,8 +27,9 @@\n> >  \n> >  #include \"test.h\"\n> >  \n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  class IPAInterfaceTest : public Test, public Object\n> >  {\n> > @@ -111,7 +112,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >  \n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationInit)\n> >                         dispatcher->processEvents();\n> >  \n> > @@ -123,7 +124,7 @@ protected:\n> >  \n> >                 /* Test start of IPA module. */\n> >                 ipa_->start();\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationStart)\n> >                         dispatcher->processEvents();\n> >  \n> > @@ -134,7 +135,7 @@ protected:\n> >  \n> >                 /* Test stop of IPA module. */\n> >                 ipa_->stop();\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationStop)\n> >                         dispatcher->processEvents();\n> >  \n> > diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp\n> > index 7e90e629e9ac..304e613bc984 100644\n> > --- a/test/ipc/unixsocket.cpp\n> > +++ b/test/ipc/unixsocket.cpp\n> > @@ -30,8 +30,9 @@\n> >  #define CMD_LEN_CMP    3\n> >  #define CMD_JOIN       4\n> >  \n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  int calculateLength(int fd)\n> >  {\n> > @@ -430,7 +431,7 @@ private:\n> >                 if (ret)\n> >                         return ret;\n> >  \n> > -               timeout.start(200);\n> > +               timeout.start(200ms);\n> >                 while (!callDone_) {\n> >                         if (!timeout.isRunning()) {\n> >                                 cerr << \"Call timeout!\" << endl;\n> > diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp\n> > index 2484c58f2fa9..966b80cf3af7 100644\n> > --- a/test/log/log_process.cpp\n> > +++ b/test/log/log_process.cpp\n> > @@ -26,8 +26,9 @@\n> >  \n> >  #include \"test.h\"\n> >  \n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  static const string message(\"hello from the child\");\n> >  \n> > @@ -80,7 +81,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >  \n> > -               timeout.start(200);\n> > +               timeout.start(200ms);\n> >                 while (timeout.isRunning())\n> >                         dispatcher->processEvents();\n> >  \n> > diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp\n> > index b410756b3288..cb6940c6a7db 100644\n> > --- a/test/process/process_test.cpp\n> > +++ b/test/process/process_test.cpp\n> > @@ -18,8 +18,9 @@\n> >  \n> >  #include \"test.h\"\n> >  \n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  class ProcessTestChild\n> >  {\n> > @@ -61,7 +62,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >  \n> > -               timeout.start(2000);\n> > +               timeout.start(2000ms);\n> >                 while (timeout.isRunning() && exitStatus_ == Process::NotExited)\n> >                         dispatcher->processEvents();\n> >  \n> > diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp\n> > index f7e8743da9e6..618217538779 100644\n> > --- a/test/timer-thread.cpp\n> > +++ b/test/timer-thread.cpp\n> > @@ -14,8 +14,9 @@\n> >  \n> >  #include \"test.h\"\n> >  \n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  class TimeoutHandler : public Object\n> >  {\n> > @@ -24,13 +25,13 @@ public:\n> >                 : timer_(this), timeout_(false)\n> >         {\n> >                 timer_.timeout.connect(this, &TimeoutHandler::timeoutHandler);\n> > -               timer_.start(100);\n> > +               timer_.start(100ms);\n> >         }\n> >  \n> >         void restart()\n> >         {\n> >                 timeout_ = false;\n> > -               timer_.start(100);\n> > +               timer_.start(100ms);\n> >         }\n> >  \n> >         bool timeout() const\n> > diff --git a/test/timer.cpp b/test/timer.cpp\n> > index be79d0100a58..0f01c3cb00ea 100644\n> > --- a/test/timer.cpp\n> > +++ b/test/timer.cpp\n> > @@ -14,8 +14,9 @@\n> >  \n> >  #include \"test.h\"\n> >  \n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  class ManagedTimer : public Timer\n> >  {\n> > @@ -26,7 +27,7 @@ public:\n> >                 timeout.connect(this, &ManagedTimer::timeoutHandler);\n> >         }\n> >  \n> > -       void start(int msec)\n> > +       void start(std::chrono::milliseconds msec)\n> >         {\n> >                 count_ = 0;\n> >                 start_ = std::chrono::steady_clock::now();\n> > @@ -82,7 +83,7 @@ protected:\n> >                 ManagedTimer timer2;\n> >  \n> >                 /* Timer expiration. */\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >  \n> >                 if (!timer.isRunning()) {\n> >                         cout << \"Timer expiration test failed\" << endl;\n> > @@ -101,7 +102,7 @@ protected:\n> >                  * Nanosecond resolution in a 32 bit value wraps at 4.294967\n> >                  * seconds (0xFFFFFFFF / 1000000)\n> >                  */\n> > -               timer.start(4295);\n> > +               timer.start(4295ms);\n> >                 dispatcher->processEvents();\n> >  \n> >                 if (timer.hasFailed()) {\n> > @@ -110,7 +111,7 @@ protected:\n> >                 }\n> >  \n> >                 /* Timer restart. */\n> > -               timer.start(500);\n> > +               timer.start(500ms);\n> >  \n> >                 if (!timer.isRunning()) {\n> >                         cout << \"Timer restart test failed\" << endl;\n> > @@ -125,9 +126,9 @@ protected:\n> >                 }\n> >  \n> >                 /* Timer restart before expiration. */\n> > -               timer.start(50);\n> > -               timer.start(100);\n> > -               timer.start(150);\n> > +               timer.start(50ms);\n> > +               timer.start(100ms);\n> > +               timer.start(150ms);\n> >  \n> >                 dispatcher->processEvents();\n> >  \n> > @@ -147,8 +148,8 @@ protected:\n> >                 }\n> >  \n> >                 /* Two timers. */\n> > -               timer.start(1000);\n> > -               timer2.start(300);\n> > +               timer.start(1000ms);\n> > +               timer2.start(300ms);\n> >  \n> >                 dispatcher->processEvents();\n> >  \n> > @@ -170,8 +171,8 @@ protected:\n> >                 }\n> >  \n> >                 /* Restart timer before expiration. */\n> > -               timer.start(1000);\n> > -               timer2.start(300);\n> > +               timer.start(1000ms);\n> > +               timer2.start(300ms);\n> >  \n> >                 dispatcher->processEvents();\n> >  \n> > @@ -180,7 +181,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >  \n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >  \n> >                 dispatcher->processEvents();\n> >  \n> > @@ -194,10 +195,10 @@ protected:\n> >                  * deleted. This will result in a crash on failure.\n> >                  */\n> >                 ManagedTimer *dyntimer = new ManagedTimer();\n> > -               dyntimer->start(100);\n> > +               dyntimer->start(100ms);\n> >                 delete dyntimer;\n> >  \n> > -               timer.start(200);\n> > +               timer.start(200ms);\n> >                 dispatcher->processEvents();\n> >  \n> >                 return TestPass;\n> > diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp\n> > index 75ee93ce5261..fa856ab6b5a8 100644\n> > --- a/test/v4l2_videodevice/buffer_sharing.cpp\n> > +++ b/test/v4l2_videodevice/buffer_sharing.cpp\n> > @@ -21,6 +21,7 @@\n> >  #include \"v4l2_videodevice_test.h\"\n> >  \n> >  using namespace libcamera;\n> > +using namespace std::chrono_literals;\n> >  \n> >  class BufferSharingTest : public V4L2VideoDeviceTest\n> >  {\n> > @@ -145,7 +146,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >  \n> > -               timeout.start(10000);\n> > +               timeout.start(10000ms);\n> >                 while (timeout.isRunning()) {\n> >                         dispatcher->processEvents();\n> >                         if (framesCaptured_ > 30 && framesOutput_ > 30)\n> > diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp\n> > index 3aa4ca0b6955..42e1e671790b 100644\n> > --- a/test/v4l2_videodevice/capture_async.cpp\n> > +++ b/test/v4l2_videodevice/capture_async.cpp\n> > @@ -16,6 +16,7 @@\n> >  #include \"v4l2_videodevice_test.h\"\n> >  \n> >  using namespace libcamera;\n> > +using namespace std::chrono_literals;\n> >  \n> >  class CaptureAsyncTest : public V4L2VideoDeviceTest\n> >  {\n> > @@ -60,7 +61,7 @@ protected:\n> >                 if (ret)\n> >                         return TestFail;\n> >  \n> > -               timeout.start(10000);\n> > +               timeout.start(10000ms);\n> >                 while (timeout.isRunning()) {\n> >                         dispatcher->processEvents();\n> >                         if (frames > 30)\n> > diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> > index ebf3e245f86b..852b853fa81a 100644\n> > --- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> > +++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> > @@ -19,8 +19,9 @@\n> >  \n> >  #include \"test.h\"\n> >  \n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >  \n> >  class V4L2M2MDeviceTest : public Test\n> >  {\n> > @@ -155,7 +156,7 @@ protected:\n> >                 }\n> >  \n> >                 Timer timeout;\n> > -               timeout.start(5000);\n> > +               timeout.start(5000ms);\n> >                 while (timeout.isRunning()) {\n> >                         dispatcher->processEvents();\n> >                         if (captureFrames_ > 30)\n> > \n> > base-commit: a8284e3570de133960458c5703e75dc9e8e737c8\n> > -- \n> > Regards,\n> > \n> > Laurent Pinchart\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9F9C5C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Mar 2022 01:02:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DE90D604C6;\n\tWed, 23 Mar 2022 02:02:57 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CBCE604C6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Mar 2022 02:02:56 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AF5D39DE;\n\tWed, 23 Mar 2022 02:02:55 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647997377;\n\tbh=RQsdGhZX71oAkVbHa+wsCwNjQr/eqF5hUVscpL2SijI=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Z3Ui8SjIUnPBv8b0KES9OcoeZQ0e3pGaoMPCZtcsIWV+iH23Tmcviir+yiB1V0e+X\n\tMGeVg8yNQPUpWwhiHm9r9ChDuvqKJ+WdFUdwV4ELkp51Ttf3d3q9o9/0mwePDJTqVW\n\tRmlZqfxHnBMLq78fQsK5KZ/k/htmMsiat0kYV/vv6TdG8Dh5DHEybY3j/N3Ogyq6J5\n\thpYTBeaiq9gnzuEbb460378gdyodj09xAi2hCMm2r/Iqk2k8+W3MGZX0HTNrCrNTd0\n\ti5G8+XzJbi+vSjA9vcsGDZJWUxibj9zPuNmCKJlY+Up7TVV9EeIB6hN3gaTPdHuOfB\n\t1EI4MU2KPkgBg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1647997376;\n\tbh=RQsdGhZX71oAkVbHa+wsCwNjQr/eqF5hUVscpL2SijI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OmAkZA9l0hd+RF1A3ISTPiAXNRFw9Q86v+axXvwunjWqQEetxPexVfVRCHX5UJCdy\n\tfmU9tpm4//0SXyE4NijjseMZ7pADFDoAY46Xaxlg+yPRfnVLqdQdPIiW9HimaKk9Sv\n\tgdXP3m86rrr5V7Cf5q9aLpc4Cd34efWvtQI5taIg="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"OmAkZA9l\"; dkim-atps=neutral","Date":"Wed, 23 Mar 2022 03:02:36 +0200","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YjpxrOhPCym85SiY@pendragon.ideasonboard.com>","References":"<20220322204248.9226-1-laurent.pinchart@ideasonboard.com>\n\t<164798935424.506124.5289342867167838003@Monstersaurus>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<164798935424.506124.5289342867167838003@Monstersaurus>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: base: timer: Drop start()\n\toverload with int argument","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22382,"web_url":"https://patchwork.libcamera.org/comment/22382/","msgid":"<3b4c1a48-d33c-0f34-7f01-89229ae93a2f@ideasonboard.com>","date":"2022-03-23T06:56:07","subject":"Re: [libcamera-devel] [PATCH] libcamera: base: timer: Drop start()\n\toverload with int argument","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hello\n\nOn 3/23/22 02:12, Laurent Pinchart via libcamera-devel wrote:\n> The start(unsigned int msec) overload is error-prone, as the argument\n> unit can easily be mistaken in callers. Drop it and update all callers\n> to use the start(std::chrono::milliseconds) overload instead.\n>\n> The callers now need to use std::chrono_literals. The using statement\n> could be added to timer.h for convenience, but \"using\" is discouraged in\n> header files to avoid namespace pollution. Update the callers instead,\n> and while at it, sort the \"using\" statements alphabetically in tests.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n> ---\n>   include/libcamera/base/timer.h           |  1 -\n>   src/libcamera/base/timer.cpp             | 10 --------\n>   src/libcamera/ipc_pipe_unixsocket.cpp    |  4 ++-\n>   test/camera/buffer_import.cpp            |  3 ++-\n>   test/camera/camera_reconfigure.cpp       |  3 ++-\n>   test/camera/capture.cpp                  |  3 ++-\n>   test/event-dispatcher.cpp                |  9 ++++---\n>   test/event.cpp                           | 11 +++++----\n>   test/fence.cpp                           |  6 ++---\n>   test/hotplug-cameras.cpp                 |  5 ++--\n>   test/ipa/ipa_interface_test.cpp          |  9 ++++---\n>   test/ipc/unixsocket.cpp                  |  5 ++--\n>   test/log/log_process.cpp                 |  5 ++--\n>   test/process/process_test.cpp            |  5 ++--\n>   test/timer-thread.cpp                    |  7 +++---\n>   test/timer.cpp                           | 31 ++++++++++++------------\n>   test/v4l2_videodevice/buffer_sharing.cpp |  3 ++-\n>   test/v4l2_videodevice/capture_async.cpp  |  3 ++-\n>   test/v4l2_videodevice/v4l2_m2mdevice.cpp |  5 ++--\n>   19 files changed, 67 insertions(+), 61 deletions(-)\n>\n> diff --git a/include/libcamera/base/timer.h b/include/libcamera/base/timer.h\n> index 09f1d3229bd5..759b68ada1e8 100644\n> --- a/include/libcamera/base/timer.h\n> +++ b/include/libcamera/base/timer.h\n> @@ -25,7 +25,6 @@ public:\n>   \tTimer(Object *parent = nullptr);\n>   \t~Timer();\n>   \n> -\tvoid start(unsigned int msec) { start(std::chrono::milliseconds(msec)); }\n>   \tvoid start(std::chrono::milliseconds duration);\n>   \tvoid start(std::chrono::steady_clock::time_point deadline);\n>   \tvoid stop();\n> diff --git a/src/libcamera/base/timer.cpp b/src/libcamera/base/timer.cpp\n> index 187336e3a1a4..74b060af32ff 100644\n> --- a/src/libcamera/base/timer.cpp\n> +++ b/src/libcamera/base/timer.cpp\n> @@ -62,16 +62,6 @@ Timer::~Timer()\n>   \tstop();\n>   }\n>   \n> -/**\n> - * \\fn Timer::start(unsigned int msec)\n> - * \\brief Start or restart the timer with a timeout of \\a msec\n> - * \\param[in] msec The timer duration in milliseconds\n> - *\n> - * If the timer is already running it will be stopped and restarted.\n> - *\n> - * \\context This function is \\threadbound.\n> - */\n> -\n>   /**\n>    * \\brief Start or restart the timer with a timeout of \\a duration\n>    * \\param[in] duration The timer duration in milliseconds\n> diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp\n> index 3ef907090131..da2cffc3b149 100644\n> --- a/src/libcamera/ipc_pipe_unixsocket.cpp\n> +++ b/src/libcamera/ipc_pipe_unixsocket.cpp\n> @@ -18,6 +18,8 @@\n>   #include \"libcamera/internal/ipc_unixsocket.h\"\n>   #include \"libcamera/internal/process.h\"\n>   \n> +using namespace std::chrono_literals;\n> +\n>   namespace libcamera {\n>   \n>   LOG_DECLARE_CATEGORY(IPCPipe)\n> @@ -126,7 +128,7 @@ int IPCPipeUnixSocket::call(const IPCUnixSocket::Payload &message,\n>   \t}\n>   \n>   \t/* \\todo Make this less dangerous, see IPCPipe::sendSync() */\n> -\ttimeout.start(2000);\n> +\ttimeout.start(2000ms);\n>   \twhile (!iter->second.done) {\n>   \t\tif (!timeout.isRunning()) {\n>   \t\t\tLOG(IPCPipe, Error) << \"Call timeout!\";\n> diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\n> index c504ea09e64b..9288400474a7 100644\n> --- a/test/camera/buffer_import.cpp\n> +++ b/test/camera/buffer_import.cpp\n> @@ -25,6 +25,7 @@\n>   #include \"test.h\"\n>   \n>   using namespace libcamera;\n> +using namespace std::chrono_literals;\n>   \n>   namespace {\n>   \n> @@ -135,7 +136,7 @@ protected:\n>   \t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n>   \n>   \t\tTimer timer;\n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \t\twhile (timer.isRunning())\n>   \t\t\tdispatcher->processEvents();\n>   \n> diff --git a/test/camera/camera_reconfigure.cpp b/test/camera/camera_reconfigure.cpp\n> index 0fd8ab70d561..f6076baa0a31 100644\n> --- a/test/camera/camera_reconfigure.cpp\n> +++ b/test/camera/camera_reconfigure.cpp\n> @@ -23,6 +23,7 @@\n>   \n>   using namespace libcamera;\n>   using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   namespace {\n>   \n> @@ -117,7 +118,7 @@ private:\n>   \t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n>   \n>   \t\tTimer timer;\n> -\t\ttimer.start(100);\n> +\t\ttimer.start(100ms);\n>   \t\twhile (timer.isRunning())\n>   \t\t\tdispatcher->processEvents();\n>   \n> diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> index f3824f95cbd3..de824083dfed 100644\n> --- a/test/camera/capture.cpp\n> +++ b/test/camera/capture.cpp\n> @@ -18,6 +18,7 @@\n>   \n>   using namespace libcamera;\n>   using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   namespace {\n>   \n> @@ -137,7 +138,7 @@ protected:\n>   \t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n>   \n>   \t\tTimer timer;\n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \t\twhile (timer.isRunning())\n>   \t\t\tdispatcher->processEvents();\n>   \n> diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp\n> index 1cc17b045ec0..9b07ab2b61d7 100644\n> --- a/test/event-dispatcher.cpp\n> +++ b/test/event-dispatcher.cpp\n> @@ -16,8 +16,9 @@\n>   \n>   #include \"test.h\"\n>   \n> -using namespace std;\n>   using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   static EventDispatcher *dispatcher;\n>   static bool interrupt;\n> @@ -50,7 +51,7 @@ protected:\n>   \t\t/* Event processing interruption by signal. */\n>   \t\tstd::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();\n>   \n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \n>   \t\tstruct itimerval itimer = {};\n>   \t\titimer.it_value.tv_usec = 500000;\n> @@ -69,7 +70,7 @@ protected:\n>   \t\t}\n>   \n>   \t\t/* Event processing interruption. */\n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \t\tdispatcher->interrupt();\n>   \n>   \t\tdispatcher->processEvents();\n> @@ -79,7 +80,7 @@ protected:\n>   \t\t\treturn TestFail;\n>   \t\t}\n>   \n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \t\titimer.it_value.tv_usec = 500000;\n>   \t\tinterrupt = true;\n>   \t\tsetitimer(ITIMER_REAL, &itimer, nullptr);\n> diff --git a/test/event.cpp b/test/event.cpp\n> index d4765eb14d12..19dceae123dd 100644\n> --- a/test/event.cpp\n> +++ b/test/event.cpp\n> @@ -16,8 +16,9 @@\n>   \n>   #include \"test.h\"\n>   \n> -using namespace std;\n>   using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   class EventTest : public Test\n>   {\n> @@ -55,7 +56,7 @@ protected:\n>   \t\t\treturn TestFail;\n>   \t\t}\n>   \n> -\t\ttimeout.start(100);\n> +\t\ttimeout.start(100ms);\n>   \t\tdispatcher->processEvents();\n>   \t\ttimeout.stop();\n>   \n> @@ -67,7 +68,7 @@ protected:\n>   \t\t/* Test read notification without data. */\n>   \t\tnotified_ = false;\n>   \n> -\t\ttimeout.start(100);\n> +\t\ttimeout.start(100ms);\n>   \t\tdispatcher->processEvents();\n>   \t\ttimeout.stop();\n>   \n> @@ -86,7 +87,7 @@ protected:\n>   \t\t\treturn TestFail;\n>   \t\t}\n>   \n> -\t\ttimeout.start(100);\n> +\t\ttimeout.start(100ms);\n>   \t\tdispatcher->processEvents();\n>   \t\ttimeout.stop();\n>   \n> @@ -99,7 +100,7 @@ protected:\n>   \t\tnotified_ = false;\n>   \t\tnotifier_->setEnabled(true);\n>   \n> -\t\ttimeout.start(100);\n> +\t\ttimeout.start(100ms);\n>   \t\tdispatcher->processEvents();\n>   \t\ttimeout.stop();\n>   \n> diff --git a/test/fence.cpp b/test/fence.cpp\n> index 524db2a10757..1e38bc2f8790 100644\n> --- a/test/fence.cpp\n> +++ b/test/fence.cpp\n> @@ -22,9 +22,9 @@\n>   #include \"camera_test.h\"\n>   #include \"test.h\"\n>   \n> -using namespace std::chrono_literals;\n>   using namespace libcamera;\n>   using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   class FenceTest : public CameraTest, public Test\n>   {\n> @@ -316,7 +316,7 @@ int FenceTest::run()\n>   \n>   \t/* Loop for one second. */\n>   \tTimer timer;\n> -\ttimer.start(1000);\n> +\ttimer.start(1000ms);\n>   \twhile (timer.isRunning() && expectedCompletionResult_) {\n>   \t\tif (completedRequest_ == signalledRequestId_ && setFence_)\n>   \t\t\t/*\n> @@ -324,7 +324,7 @@ int FenceTest::run()\n>   \t\t\t * been re-queued with a fence. Start the timer to\n>   \t\t\t * signal the fence in 10 msec.\n>   \t\t\t */\n> -\t\t\tfenceTimer.start(10);\n> +\t\t\tfenceTimer.start(10ms);\n>   \n>   \t\tdispatcher_->processEvents();\n>   \t}\n> diff --git a/test/hotplug-cameras.cpp b/test/hotplug-cameras.cpp\n> index df56040350c5..5d9260a241ec 100644\n> --- a/test/hotplug-cameras.cpp\n> +++ b/test/hotplug-cameras.cpp\n> @@ -22,6 +22,7 @@\n>   #include \"test.h\"\n>   \n>   using namespace libcamera;\n> +using namespace std::chrono_literals;\n>   \n>   class HotplugTest : public Test\n>   {\n> @@ -88,7 +89,7 @@ protected:\n>   \t\tstd::ofstream(uvcDriverDir_ + \"unbind\", std::ios::binary)\n>   \t\t\t<< uvcDeviceDir;\n>   \t\tTimer timer;\n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \t\twhile (timer.isRunning() && !cameraRemoved_)\n>   \t\t\tThread::current()->eventDispatcher()->processEvents();\n>   \t\tif (!cameraRemoved_) {\n> @@ -99,7 +100,7 @@ protected:\n>   \t\t/* Bind the camera again and process events. */\n>   \t\tstd::ofstream(uvcDriverDir_ + \"bind\", std::ios::binary)\n>   \t\t\t<< uvcDeviceDir;\n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \t\twhile (timer.isRunning() && !cameraAdded_)\n>   \t\t\tThread::current()->eventDispatcher()->processEvents();\n>   \t\tif (!cameraAdded_) {\n> diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\n> index 43562e608506..3c0df843ea61 100644\n> --- a/test/ipa/ipa_interface_test.cpp\n> +++ b/test/ipa/ipa_interface_test.cpp\n> @@ -27,8 +27,9 @@\n>   \n>   #include \"test.h\"\n>   \n> -using namespace std;\n>   using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   class IPAInterfaceTest : public Test, public Object\n>   {\n> @@ -111,7 +112,7 @@ protected:\n>   \t\t\treturn TestFail;\n>   \t\t}\n>   \n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \t\twhile (timer.isRunning() && trace_ != ipa::vimc::IPAOperationInit)\n>   \t\t\tdispatcher->processEvents();\n>   \n> @@ -123,7 +124,7 @@ protected:\n>   \n>   \t\t/* Test start of IPA module. */\n>   \t\tipa_->start();\n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \t\twhile (timer.isRunning() && trace_ != ipa::vimc::IPAOperationStart)\n>   \t\t\tdispatcher->processEvents();\n>   \n> @@ -134,7 +135,7 @@ protected:\n>   \n>   \t\t/* Test stop of IPA module. */\n>   \t\tipa_->stop();\n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \t\twhile (timer.isRunning() && trace_ != ipa::vimc::IPAOperationStop)\n>   \t\t\tdispatcher->processEvents();\n>   \n> diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp\n> index 7e90e629e9ac..304e613bc984 100644\n> --- a/test/ipc/unixsocket.cpp\n> +++ b/test/ipc/unixsocket.cpp\n> @@ -30,8 +30,9 @@\n>   #define CMD_LEN_CMP\t3\n>   #define CMD_JOIN\t4\n>   \n> -using namespace std;\n>   using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   int calculateLength(int fd)\n>   {\n> @@ -430,7 +431,7 @@ private:\n>   \t\tif (ret)\n>   \t\t\treturn ret;\n>   \n> -\t\ttimeout.start(200);\n> +\t\ttimeout.start(200ms);\n>   \t\twhile (!callDone_) {\n>   \t\t\tif (!timeout.isRunning()) {\n>   \t\t\t\tcerr << \"Call timeout!\" << endl;\n> diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp\n> index 2484c58f2fa9..966b80cf3af7 100644\n> --- a/test/log/log_process.cpp\n> +++ b/test/log/log_process.cpp\n> @@ -26,8 +26,9 @@\n>   \n>   #include \"test.h\"\n>   \n> -using namespace std;\n>   using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   static const string message(\"hello from the child\");\n>   \n> @@ -80,7 +81,7 @@ protected:\n>   \t\t\treturn TestFail;\n>   \t\t}\n>   \n> -\t\ttimeout.start(200);\n> +\t\ttimeout.start(200ms);\n>   \t\twhile (timeout.isRunning())\n>   \t\t\tdispatcher->processEvents();\n>   \n> diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp\n> index b410756b3288..cb6940c6a7db 100644\n> --- a/test/process/process_test.cpp\n> +++ b/test/process/process_test.cpp\n> @@ -18,8 +18,9 @@\n>   \n>   #include \"test.h\"\n>   \n> -using namespace std;\n>   using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   class ProcessTestChild\n>   {\n> @@ -61,7 +62,7 @@ protected:\n>   \t\t\treturn TestFail;\n>   \t\t}\n>   \n> -\t\ttimeout.start(2000);\n> +\t\ttimeout.start(2000ms);\n>   \t\twhile (timeout.isRunning() && exitStatus_ == Process::NotExited)\n>   \t\t\tdispatcher->processEvents();\n>   \n> diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp\n> index f7e8743da9e6..618217538779 100644\n> --- a/test/timer-thread.cpp\n> +++ b/test/timer-thread.cpp\n> @@ -14,8 +14,9 @@\n>   \n>   #include \"test.h\"\n>   \n> -using namespace std;\n>   using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   class TimeoutHandler : public Object\n>   {\n> @@ -24,13 +25,13 @@ public:\n>   \t\t: timer_(this), timeout_(false)\n>   \t{\n>   \t\ttimer_.timeout.connect(this, &TimeoutHandler::timeoutHandler);\n> -\t\ttimer_.start(100);\n> +\t\ttimer_.start(100ms);\n>   \t}\n>   \n>   \tvoid restart()\n>   \t{\n>   \t\ttimeout_ = false;\n> -\t\ttimer_.start(100);\n> +\t\ttimer_.start(100ms);\n>   \t}\n>   \n>   \tbool timeout() const\n> diff --git a/test/timer.cpp b/test/timer.cpp\n> index be79d0100a58..0f01c3cb00ea 100644\n> --- a/test/timer.cpp\n> +++ b/test/timer.cpp\n> @@ -14,8 +14,9 @@\n>   \n>   #include \"test.h\"\n>   \n> -using namespace std;\n>   using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   class ManagedTimer : public Timer\n>   {\n> @@ -26,7 +27,7 @@ public:\n>   \t\ttimeout.connect(this, &ManagedTimer::timeoutHandler);\n>   \t}\n>   \n> -\tvoid start(int msec)\n> +\tvoid start(std::chrono::milliseconds msec)\n>   \t{\n>   \t\tcount_ = 0;\n>   \t\tstart_ = std::chrono::steady_clock::now();\n> @@ -82,7 +83,7 @@ protected:\n>   \t\tManagedTimer timer2;\n>   \n>   \t\t/* Timer expiration. */\n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \n>   \t\tif (!timer.isRunning()) {\n>   \t\t\tcout << \"Timer expiration test failed\" << endl;\n> @@ -101,7 +102,7 @@ protected:\n>   \t\t * Nanosecond resolution in a 32 bit value wraps at 4.294967\n>   \t\t * seconds (0xFFFFFFFF / 1000000)\n>   \t\t */\n> -\t\ttimer.start(4295);\n> +\t\ttimer.start(4295ms);\n>   \t\tdispatcher->processEvents();\n>   \n>   \t\tif (timer.hasFailed()) {\n> @@ -110,7 +111,7 @@ protected:\n>   \t\t}\n>   \n>   \t\t/* Timer restart. */\n> -\t\ttimer.start(500);\n> +\t\ttimer.start(500ms);\n>   \n>   \t\tif (!timer.isRunning()) {\n>   \t\t\tcout << \"Timer restart test failed\" << endl;\n> @@ -125,9 +126,9 @@ protected:\n>   \t\t}\n>   \n>   \t\t/* Timer restart before expiration. */\n> -\t\ttimer.start(50);\n> -\t\ttimer.start(100);\n> -\t\ttimer.start(150);\n> +\t\ttimer.start(50ms);\n> +\t\ttimer.start(100ms);\n> +\t\ttimer.start(150ms);\n>   \n>   \t\tdispatcher->processEvents();\n>   \n> @@ -147,8 +148,8 @@ protected:\n>   \t\t}\n>   \n>   \t\t/* Two timers. */\n> -\t\ttimer.start(1000);\n> -\t\ttimer2.start(300);\n> +\t\ttimer.start(1000ms);\n> +\t\ttimer2.start(300ms);\n>   \n>   \t\tdispatcher->processEvents();\n>   \n> @@ -170,8 +171,8 @@ protected:\n>   \t\t}\n>   \n>   \t\t/* Restart timer before expiration. */\n> -\t\ttimer.start(1000);\n> -\t\ttimer2.start(300);\n> +\t\ttimer.start(1000ms);\n> +\t\ttimer2.start(300ms);\n>   \n>   \t\tdispatcher->processEvents();\n>   \n> @@ -180,7 +181,7 @@ protected:\n>   \t\t\treturn TestFail;\n>   \t\t}\n>   \n> -\t\ttimer.start(1000);\n> +\t\ttimer.start(1000ms);\n>   \n>   \t\tdispatcher->processEvents();\n>   \n> @@ -194,10 +195,10 @@ protected:\n>   \t\t * deleted. This will result in a crash on failure.\n>   \t\t */\n>   \t\tManagedTimer *dyntimer = new ManagedTimer();\n> -\t\tdyntimer->start(100);\n> +\t\tdyntimer->start(100ms);\n>   \t\tdelete dyntimer;\n>   \n> -\t\ttimer.start(200);\n> +\t\ttimer.start(200ms);\n>   \t\tdispatcher->processEvents();\n>   \n>   \t\treturn TestPass;\n> diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp\n> index 75ee93ce5261..fa856ab6b5a8 100644\n> --- a/test/v4l2_videodevice/buffer_sharing.cpp\n> +++ b/test/v4l2_videodevice/buffer_sharing.cpp\n> @@ -21,6 +21,7 @@\n>   #include \"v4l2_videodevice_test.h\"\n>   \n>   using namespace libcamera;\n> +using namespace std::chrono_literals;\n>   \n>   class BufferSharingTest : public V4L2VideoDeviceTest\n>   {\n> @@ -145,7 +146,7 @@ protected:\n>   \t\t\treturn TestFail;\n>   \t\t}\n>   \n> -\t\ttimeout.start(10000);\n> +\t\ttimeout.start(10000ms);\n>   \t\twhile (timeout.isRunning()) {\n>   \t\t\tdispatcher->processEvents();\n>   \t\t\tif (framesCaptured_ > 30 && framesOutput_ > 30)\n> diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp\n> index 3aa4ca0b6955..42e1e671790b 100644\n> --- a/test/v4l2_videodevice/capture_async.cpp\n> +++ b/test/v4l2_videodevice/capture_async.cpp\n> @@ -16,6 +16,7 @@\n>   #include \"v4l2_videodevice_test.h\"\n>   \n>   using namespace libcamera;\n> +using namespace std::chrono_literals;\n>   \n>   class CaptureAsyncTest : public V4L2VideoDeviceTest\n>   {\n> @@ -60,7 +61,7 @@ protected:\n>   \t\tif (ret)\n>   \t\t\treturn TestFail;\n>   \n> -\t\ttimeout.start(10000);\n> +\t\ttimeout.start(10000ms);\n>   \t\twhile (timeout.isRunning()) {\n>   \t\t\tdispatcher->processEvents();\n>   \t\t\tif (frames > 30)\n> diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> index ebf3e245f86b..852b853fa81a 100644\n> --- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> +++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> @@ -19,8 +19,9 @@\n>   \n>   #include \"test.h\"\n>   \n> -using namespace std;\n>   using namespace libcamera;\n> +using namespace std;\n> +using namespace std::chrono_literals;\n>   \n>   class V4L2M2MDeviceTest : public Test\n>   {\n> @@ -155,7 +156,7 @@ protected:\n>   \t\t}\n>   \n>   \t\tTimer timeout;\n> -\t\ttimeout.start(5000);\n> +\t\ttimeout.start(5000ms);\n>   \t\twhile (timeout.isRunning()) {\n>   \t\t\tdispatcher->processEvents();\n>   \t\t\tif (captureFrames_ > 30)\n>\n> base-commit: a8284e3570de133960458c5703e75dc9e8e737c8","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C6048C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Mar 2022 06:56:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F1975604DC;\n\tWed, 23 Mar 2022 07:56:16 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C1E73604C3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Mar 2022 07:56:14 +0100 (CET)","from [192.168.1.106] (unknown [103.251.226.192])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 510E79DE;\n\tWed, 23 Mar 2022 07:56:13 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648018577;\n\tbh=CoRe1LxPoKsKui4CELRKdY7/k79OP7NDPzzZTTpKK+o=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Mv2MlyQK0mYRfp81kzXTHv/f28m5lvPlyLJ5kZc66uk3H4REQplmoDN2YozTwGccl\n\t0ZJsGS8MTnD9jjq2f72/IqkxQI8MwadCSoQIx/Jd4IuRA7WHKBbuk3SxaBpNKvK4Au\n\tFzw+4Odq5BygYRGhMAdjMB7g70XGDItyB8tt3zqg3pOf91mXNVFVBU/8OoHlPm+ln6\n\tkGBTFVoB9dMlcVEM7WkbWPtneSnTlEp0u9EkVlVrUdnhjjRYd+XLJrbz3KU43C2UUc\n\tfMccWn3d9/s4ynWGze4oFzAFo2xJH4q6cLEXA7MvgSSy1QpH9tPWggjQbBIxEwq7vx\n\tXFUB3c7ssQIbA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1648018574;\n\tbh=CoRe1LxPoKsKui4CELRKdY7/k79OP7NDPzzZTTpKK+o=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=MCOxxQeeLBQ07A5L0rOX3SRTX8CJPDyJfBu+FeQAE6Q7MdLfPdvsoOm9X9RxFpYqz\n\t+N1HmEK8ktnxLj1sSUGkwh+5uYtPB7ypXa8C6PX40yVLTasv10pFZp/T4ResE0O3/S\n\tNVNRr94gvfInsih/rbnBnCTwF5FFE+K8x5C8yMJw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"MCOxxQee\"; dkim-atps=neutral","Message-ID":"<3b4c1a48-d33c-0f34-7f01-89229ae93a2f@ideasonboard.com>","Date":"Wed, 23 Mar 2022 12:26:07 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.4.1","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20220322204248.9226-1-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20220322204248.9226-1-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH] libcamera: base: timer: Drop start()\n\toverload with int argument","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22383,"web_url":"https://patchwork.libcamera.org/comment/22383/","msgid":"<CAEmqJPqeGhYqa1ukMR8+4RMbZDX_DShHJZZO+x93VmtYg6GF3Q@mail.gmail.com>","date":"2022-03-23T07:12:48","subject":"Re: [libcamera-devel] [PATCH] libcamera: base: timer: Drop start()\n\toverload with int argument","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"On Tue, 22 Mar 2022 at 22:49, Kieran Bingham via libcamera-devel <\nlibcamera-devel@lists.libcamera.org> wrote:\n\n> Hi Laurent,\n>\n> Quoting Laurent Pinchart via libcamera-devel (2022-03-22 20:42:48)\n> > The start(unsigned int msec) overload is error-prone, as the argument\n> > unit can easily be mistaken in callers. Drop it and update all callers\n> > to use the start(std::chrono::milliseconds) overload instead.\n> >\n> > The callers now need to use std::chrono_literals. The using statement\n> > could be added to timer.h for convenience, but \"using\" is discouraged in\n> > header files to avoid namespace pollution. Update the callers instead,\n> > and while at it, sort the \"using\" statements alphabetically in tests.\n> >\n>\n> Does a utils::Duration implicitly get cast/converted to a\n> std::chrono::milliseconds() with this now?\n>\n\nAnnoyingly not, as the utils::Duration base type is a double, and\nstd::chrono::milliseconds uses an integer.  So you need to explicitly\ndo a std::chrono::duration_cast<>.  We could consider switching the\nutils::Duration base type to an integer as well (something we had talked\nabout in the past), I very much doubt double precision is absolutely\nnecessary.\n\n\n>\n> I.e. - does this help ease Naush's patches to accept a utils::duration?\n> (Which is a good-thing-tm I think)\n>\n\nI think Laurent's intention is to move utils::Duration to the public\ninterface,\nso we may not be able to use utils::Duration in the Timer class.  That is\nnot a big issue for me, but I'll reply to that thread separately.\n\nNaush\n\n\n>\n> Anyway, I have a lot of fondness for chrono-literals. I think they\n> really help improve readability, and I expect prevent bugs.\n>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  include/libcamera/base/timer.h           |  1 -\n> >  src/libcamera/base/timer.cpp             | 10 --------\n> >  src/libcamera/ipc_pipe_unixsocket.cpp    |  4 ++-\n> >  test/camera/buffer_import.cpp            |  3 ++-\n> >  test/camera/camera_reconfigure.cpp       |  3 ++-\n> >  test/camera/capture.cpp                  |  3 ++-\n> >  test/event-dispatcher.cpp                |  9 ++++---\n> >  test/event.cpp                           | 11 +++++----\n> >  test/fence.cpp                           |  6 ++---\n> >  test/hotplug-cameras.cpp                 |  5 ++--\n> >  test/ipa/ipa_interface_test.cpp          |  9 ++++---\n> >  test/ipc/unixsocket.cpp                  |  5 ++--\n> >  test/log/log_process.cpp                 |  5 ++--\n> >  test/process/process_test.cpp            |  5 ++--\n> >  test/timer-thread.cpp                    |  7 +++---\n> >  test/timer.cpp                           | 31 ++++++++++++------------\n> >  test/v4l2_videodevice/buffer_sharing.cpp |  3 ++-\n> >  test/v4l2_videodevice/capture_async.cpp  |  3 ++-\n> >  test/v4l2_videodevice/v4l2_m2mdevice.cpp |  5 ++--\n> >  19 files changed, 67 insertions(+), 61 deletions(-)\n> >\n> > diff --git a/include/libcamera/base/timer.h\n> b/include/libcamera/base/timer.h\n> > index 09f1d3229bd5..759b68ada1e8 100644\n> > --- a/include/libcamera/base/timer.h\n> > +++ b/include/libcamera/base/timer.h\n> > @@ -25,7 +25,6 @@ public:\n> >         Timer(Object *parent = nullptr);\n> >         ~Timer();\n> >\n> > -       void start(unsigned int msec) {\n> start(std::chrono::milliseconds(msec)); }\n> >         void start(std::chrono::milliseconds duration);\n> >         void start(std::chrono::steady_clock::time_point deadline);\n> >         void stop();\n> > diff --git a/src/libcamera/base/timer.cpp b/src/libcamera/base/timer.cpp\n> > index 187336e3a1a4..74b060af32ff 100644\n> > --- a/src/libcamera/base/timer.cpp\n> > +++ b/src/libcamera/base/timer.cpp\n> > @@ -62,16 +62,6 @@ Timer::~Timer()\n> >         stop();\n> >  }\n> >\n> > -/**\n> > - * \\fn Timer::start(unsigned int msec)\n> > - * \\brief Start or restart the timer with a timeout of \\a msec\n> > - * \\param[in] msec The timer duration in milliseconds\n> > - *\n> > - * If the timer is already running it will be stopped and restarted.\n> > - *\n> > - * \\context This function is \\threadbound.\n> > - */\n> > -\n> >  /**\n> >   * \\brief Start or restart the timer with a timeout of \\a duration\n> >   * \\param[in] duration The timer duration in milliseconds\n> > diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp\n> b/src/libcamera/ipc_pipe_unixsocket.cpp\n> > index 3ef907090131..da2cffc3b149 100644\n> > --- a/src/libcamera/ipc_pipe_unixsocket.cpp\n> > +++ b/src/libcamera/ipc_pipe_unixsocket.cpp\n> > @@ -18,6 +18,8 @@\n> >  #include \"libcamera/internal/ipc_unixsocket.h\"\n> >  #include \"libcamera/internal/process.h\"\n> >\n> > +using namespace std::chrono_literals;\n> > +\n> >  namespace libcamera {\n> >\n> >  LOG_DECLARE_CATEGORY(IPCPipe)\n> > @@ -126,7 +128,7 @@ int IPCPipeUnixSocket::call(const\n> IPCUnixSocket::Payload &message,\n> >         }\n> >\n> >         /* \\todo Make this less dangerous, see IPCPipe::sendSync() */\n> > -       timeout.start(2000);\n> > +       timeout.start(2000ms);\n> >         while (!iter->second.done) {\n> >                 if (!timeout.isRunning()) {\n> >                         LOG(IPCPipe, Error) << \"Call timeout!\";\n> > diff --git a/test/camera/buffer_import.cpp\n> b/test/camera/buffer_import.cpp\n> > index c504ea09e64b..9288400474a7 100644\n> > --- a/test/camera/buffer_import.cpp\n> > +++ b/test/camera/buffer_import.cpp\n> > @@ -25,6 +25,7 @@\n> >  #include \"test.h\"\n> >\n> >  using namespace libcamera;\n> > +using namespace std::chrono_literals;\n> >\n> >  namespace {\n> >\n> > @@ -135,7 +136,7 @@ protected:\n> >                 EventDispatcher *dispatcher =\n> Thread::current()->eventDispatcher();\n> >\n> >                 Timer timer;\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning())\n> >                         dispatcher->processEvents();\n> >\n> > diff --git a/test/camera/camera_reconfigure.cpp\n> b/test/camera/camera_reconfigure.cpp\n> > index 0fd8ab70d561..f6076baa0a31 100644\n> > --- a/test/camera/camera_reconfigure.cpp\n> > +++ b/test/camera/camera_reconfigure.cpp\n> > @@ -23,6 +23,7 @@\n> >\n> >  using namespace libcamera;\n> >  using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  namespace {\n> >\n> > @@ -117,7 +118,7 @@ private:\n> >                 EventDispatcher *dispatcher =\n> Thread::current()->eventDispatcher();\n> >\n> >                 Timer timer;\n> > -               timer.start(100);\n> > +               timer.start(100ms);\n> >                 while (timer.isRunning())\n> >                         dispatcher->processEvents();\n> >\n> > diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> > index f3824f95cbd3..de824083dfed 100644\n> > --- a/test/camera/capture.cpp\n> > +++ b/test/camera/capture.cpp\n> > @@ -18,6 +18,7 @@\n> >\n> >  using namespace libcamera;\n> >  using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  namespace {\n> >\n> > @@ -137,7 +138,7 @@ protected:\n> >                 EventDispatcher *dispatcher =\n> Thread::current()->eventDispatcher();\n> >\n> >                 Timer timer;\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning())\n> >                         dispatcher->processEvents();\n> >\n> > diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp\n> > index 1cc17b045ec0..9b07ab2b61d7 100644\n> > --- a/test/event-dispatcher.cpp\n> > +++ b/test/event-dispatcher.cpp\n> > @@ -16,8 +16,9 @@\n> >\n> >  #include \"test.h\"\n> >\n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  static EventDispatcher *dispatcher;\n> >  static bool interrupt;\n> > @@ -50,7 +51,7 @@ protected:\n> >                 /* Event processing interruption by signal. */\n> >                 std::chrono::steady_clock::time_point start =\n> std::chrono::steady_clock::now();\n> >\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >\n> >                 struct itimerval itimer = {};\n> >                 itimer.it_value.tv_usec = 500000;\n> > @@ -69,7 +70,7 @@ protected:\n> >                 }\n> >\n> >                 /* Event processing interruption. */\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 dispatcher->interrupt();\n> >\n> >                 dispatcher->processEvents();\n> > @@ -79,7 +80,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 itimer.it_value.tv_usec = 500000;\n> >                 interrupt = true;\n> >                 setitimer(ITIMER_REAL, &itimer, nullptr);\n> > diff --git a/test/event.cpp b/test/event.cpp\n> > index d4765eb14d12..19dceae123dd 100644\n> > --- a/test/event.cpp\n> > +++ b/test/event.cpp\n> > @@ -16,8 +16,9 @@\n> >\n> >  #include \"test.h\"\n> >\n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  class EventTest : public Test\n> >  {\n> > @@ -55,7 +56,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >\n> > -               timeout.start(100);\n> > +               timeout.start(100ms);\n> >                 dispatcher->processEvents();\n> >                 timeout.stop();\n> >\n> > @@ -67,7 +68,7 @@ protected:\n> >                 /* Test read notification without data. */\n> >                 notified_ = false;\n> >\n> > -               timeout.start(100);\n> > +               timeout.start(100ms);\n> >                 dispatcher->processEvents();\n> >                 timeout.stop();\n> >\n> > @@ -86,7 +87,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >\n> > -               timeout.start(100);\n> > +               timeout.start(100ms);\n> >                 dispatcher->processEvents();\n> >                 timeout.stop();\n> >\n> > @@ -99,7 +100,7 @@ protected:\n> >                 notified_ = false;\n> >                 notifier_->setEnabled(true);\n> >\n> > -               timeout.start(100);\n> > +               timeout.start(100ms);\n> >                 dispatcher->processEvents();\n> >                 timeout.stop();\n> >\n> > diff --git a/test/fence.cpp b/test/fence.cpp\n> > index 524db2a10757..1e38bc2f8790 100644\n> > --- a/test/fence.cpp\n> > +++ b/test/fence.cpp\n> > @@ -22,9 +22,9 @@\n> >  #include \"camera_test.h\"\n> >  #include \"test.h\"\n> >\n> > -using namespace std::chrono_literals;\n> >  using namespace libcamera;\n> >  using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  class FenceTest : public CameraTest, public Test\n> >  {\n> > @@ -316,7 +316,7 @@ int FenceTest::run()\n> >\n> >         /* Loop for one second. */\n> >         Timer timer;\n> > -       timer.start(1000);\n> > +       timer.start(1000ms);\n> >         while (timer.isRunning() && expectedCompletionResult_) {\n> >                 if (completedRequest_ == signalledRequestId_ &&\n> setFence_)\n> >                         /*\n> > @@ -324,7 +324,7 @@ int FenceTest::run()\n> >                          * been re-queued with a fence. Start the timer\n> to\n> >                          * signal the fence in 10 msec.\n> >                          */\n> > -                       fenceTimer.start(10);\n> > +                       fenceTimer.start(10ms);\n> >\n> >                 dispatcher_->processEvents();\n> >         }\n> > diff --git a/test/hotplug-cameras.cpp b/test/hotplug-cameras.cpp\n> > index df56040350c5..5d9260a241ec 100644\n> > --- a/test/hotplug-cameras.cpp\n> > +++ b/test/hotplug-cameras.cpp\n> > @@ -22,6 +22,7 @@\n> >  #include \"test.h\"\n> >\n> >  using namespace libcamera;\n> > +using namespace std::chrono_literals;\n> >\n> >  class HotplugTest : public Test\n> >  {\n> > @@ -88,7 +89,7 @@ protected:\n> >                 std::ofstream(uvcDriverDir_ + \"unbind\", std::ios::binary)\n> >                         << uvcDeviceDir;\n> >                 Timer timer;\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning() && !cameraRemoved_)\n> >\n>  Thread::current()->eventDispatcher()->processEvents();\n> >                 if (!cameraRemoved_) {\n> > @@ -99,7 +100,7 @@ protected:\n> >                 /* Bind the camera again and process events. */\n> >                 std::ofstream(uvcDriverDir_ + \"bind\", std::ios::binary)\n> >                         << uvcDeviceDir;\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning() && !cameraAdded_)\n> >\n>  Thread::current()->eventDispatcher()->processEvents();\n> >                 if (!cameraAdded_) {\n> > diff --git a/test/ipa/ipa_interface_test.cpp\n> b/test/ipa/ipa_interface_test.cpp\n> > index 43562e608506..3c0df843ea61 100644\n> > --- a/test/ipa/ipa_interface_test.cpp\n> > +++ b/test/ipa/ipa_interface_test.cpp\n> > @@ -27,8 +27,9 @@\n> >\n> >  #include \"test.h\"\n> >\n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  class IPAInterfaceTest : public Test, public Object\n> >  {\n> > @@ -111,7 +112,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning() && trace_ !=\n> ipa::vimc::IPAOperationInit)\n> >                         dispatcher->processEvents();\n> >\n> > @@ -123,7 +124,7 @@ protected:\n> >\n> >                 /* Test start of IPA module. */\n> >                 ipa_->start();\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning() && trace_ !=\n> ipa::vimc::IPAOperationStart)\n> >                         dispatcher->processEvents();\n> >\n> > @@ -134,7 +135,7 @@ protected:\n> >\n> >                 /* Test stop of IPA module. */\n> >                 ipa_->stop();\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >                 while (timer.isRunning() && trace_ !=\n> ipa::vimc::IPAOperationStop)\n> >                         dispatcher->processEvents();\n> >\n> > diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp\n> > index 7e90e629e9ac..304e613bc984 100644\n> > --- a/test/ipc/unixsocket.cpp\n> > +++ b/test/ipc/unixsocket.cpp\n> > @@ -30,8 +30,9 @@\n> >  #define CMD_LEN_CMP    3\n> >  #define CMD_JOIN       4\n> >\n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  int calculateLength(int fd)\n> >  {\n> > @@ -430,7 +431,7 @@ private:\n> >                 if (ret)\n> >                         return ret;\n> >\n> > -               timeout.start(200);\n> > +               timeout.start(200ms);\n> >                 while (!callDone_) {\n> >                         if (!timeout.isRunning()) {\n> >                                 cerr << \"Call timeout!\" << endl;\n> > diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp\n> > index 2484c58f2fa9..966b80cf3af7 100644\n> > --- a/test/log/log_process.cpp\n> > +++ b/test/log/log_process.cpp\n> > @@ -26,8 +26,9 @@\n> >\n> >  #include \"test.h\"\n> >\n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  static const string message(\"hello from the child\");\n> >\n> > @@ -80,7 +81,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >\n> > -               timeout.start(200);\n> > +               timeout.start(200ms);\n> >                 while (timeout.isRunning())\n> >                         dispatcher->processEvents();\n> >\n> > diff --git a/test/process/process_test.cpp\n> b/test/process/process_test.cpp\n> > index b410756b3288..cb6940c6a7db 100644\n> > --- a/test/process/process_test.cpp\n> > +++ b/test/process/process_test.cpp\n> > @@ -18,8 +18,9 @@\n> >\n> >  #include \"test.h\"\n> >\n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  class ProcessTestChild\n> >  {\n> > @@ -61,7 +62,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >\n> > -               timeout.start(2000);\n> > +               timeout.start(2000ms);\n> >                 while (timeout.isRunning() && exitStatus_ ==\n> Process::NotExited)\n> >                         dispatcher->processEvents();\n> >\n> > diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp\n> > index f7e8743da9e6..618217538779 100644\n> > --- a/test/timer-thread.cpp\n> > +++ b/test/timer-thread.cpp\n> > @@ -14,8 +14,9 @@\n> >\n> >  #include \"test.h\"\n> >\n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  class TimeoutHandler : public Object\n> >  {\n> > @@ -24,13 +25,13 @@ public:\n> >                 : timer_(this), timeout_(false)\n> >         {\n> >                 timer_.timeout.connect(this,\n> &TimeoutHandler::timeoutHandler);\n> > -               timer_.start(100);\n> > +               timer_.start(100ms);\n> >         }\n> >\n> >         void restart()\n> >         {\n> >                 timeout_ = false;\n> > -               timer_.start(100);\n> > +               timer_.start(100ms);\n> >         }\n> >\n> >         bool timeout() const\n> > diff --git a/test/timer.cpp b/test/timer.cpp\n> > index be79d0100a58..0f01c3cb00ea 100644\n> > --- a/test/timer.cpp\n> > +++ b/test/timer.cpp\n> > @@ -14,8 +14,9 @@\n> >\n> >  #include \"test.h\"\n> >\n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  class ManagedTimer : public Timer\n> >  {\n> > @@ -26,7 +27,7 @@ public:\n> >                 timeout.connect(this, &ManagedTimer::timeoutHandler);\n> >         }\n> >\n> > -       void start(int msec)\n> > +       void start(std::chrono::milliseconds msec)\n> >         {\n> >                 count_ = 0;\n> >                 start_ = std::chrono::steady_clock::now();\n> > @@ -82,7 +83,7 @@ protected:\n> >                 ManagedTimer timer2;\n> >\n> >                 /* Timer expiration. */\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >\n> >                 if (!timer.isRunning()) {\n> >                         cout << \"Timer expiration test failed\" << endl;\n> > @@ -101,7 +102,7 @@ protected:\n> >                  * Nanosecond resolution in a 32 bit value wraps at\n> 4.294967\n> >                  * seconds (0xFFFFFFFF / 1000000)\n> >                  */\n> > -               timer.start(4295);\n> > +               timer.start(4295ms);\n> >                 dispatcher->processEvents();\n> >\n> >                 if (timer.hasFailed()) {\n> > @@ -110,7 +111,7 @@ protected:\n> >                 }\n> >\n> >                 /* Timer restart. */\n> > -               timer.start(500);\n> > +               timer.start(500ms);\n> >\n> >                 if (!timer.isRunning()) {\n> >                         cout << \"Timer restart test failed\" << endl;\n> > @@ -125,9 +126,9 @@ protected:\n> >                 }\n> >\n> >                 /* Timer restart before expiration. */\n> > -               timer.start(50);\n> > -               timer.start(100);\n> > -               timer.start(150);\n> > +               timer.start(50ms);\n> > +               timer.start(100ms);\n> > +               timer.start(150ms);\n> >\n> >                 dispatcher->processEvents();\n> >\n> > @@ -147,8 +148,8 @@ protected:\n> >                 }\n> >\n> >                 /* Two timers. */\n> > -               timer.start(1000);\n> > -               timer2.start(300);\n> > +               timer.start(1000ms);\n> > +               timer2.start(300ms);\n> >\n> >                 dispatcher->processEvents();\n> >\n> > @@ -170,8 +171,8 @@ protected:\n> >                 }\n> >\n> >                 /* Restart timer before expiration. */\n> > -               timer.start(1000);\n> > -               timer2.start(300);\n> > +               timer.start(1000ms);\n> > +               timer2.start(300ms);\n> >\n> >                 dispatcher->processEvents();\n> >\n> > @@ -180,7 +181,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >\n> > -               timer.start(1000);\n> > +               timer.start(1000ms);\n> >\n> >                 dispatcher->processEvents();\n> >\n> > @@ -194,10 +195,10 @@ protected:\n> >                  * deleted. This will result in a crash on failure.\n> >                  */\n> >                 ManagedTimer *dyntimer = new ManagedTimer();\n> > -               dyntimer->start(100);\n> > +               dyntimer->start(100ms);\n> >                 delete dyntimer;\n> >\n> > -               timer.start(200);\n> > +               timer.start(200ms);\n> >                 dispatcher->processEvents();\n> >\n> >                 return TestPass;\n> > diff --git a/test/v4l2_videodevice/buffer_sharing.cpp\n> b/test/v4l2_videodevice/buffer_sharing.cpp\n> > index 75ee93ce5261..fa856ab6b5a8 100644\n> > --- a/test/v4l2_videodevice/buffer_sharing.cpp\n> > +++ b/test/v4l2_videodevice/buffer_sharing.cpp\n> > @@ -21,6 +21,7 @@\n> >  #include \"v4l2_videodevice_test.h\"\n> >\n> >  using namespace libcamera;\n> > +using namespace std::chrono_literals;\n> >\n> >  class BufferSharingTest : public V4L2VideoDeviceTest\n> >  {\n> > @@ -145,7 +146,7 @@ protected:\n> >                         return TestFail;\n> >                 }\n> >\n> > -               timeout.start(10000);\n> > +               timeout.start(10000ms);\n> >                 while (timeout.isRunning()) {\n> >                         dispatcher->processEvents();\n> >                         if (framesCaptured_ > 30 && framesOutput_ > 30)\n> > diff --git a/test/v4l2_videodevice/capture_async.cpp\n> b/test/v4l2_videodevice/capture_async.cpp\n> > index 3aa4ca0b6955..42e1e671790b 100644\n> > --- a/test/v4l2_videodevice/capture_async.cpp\n> > +++ b/test/v4l2_videodevice/capture_async.cpp\n> > @@ -16,6 +16,7 @@\n> >  #include \"v4l2_videodevice_test.h\"\n> >\n> >  using namespace libcamera;\n> > +using namespace std::chrono_literals;\n> >\n> >  class CaptureAsyncTest : public V4L2VideoDeviceTest\n> >  {\n> > @@ -60,7 +61,7 @@ protected:\n> >                 if (ret)\n> >                         return TestFail;\n> >\n> > -               timeout.start(10000);\n> > +               timeout.start(10000ms);\n> >                 while (timeout.isRunning()) {\n> >                         dispatcher->processEvents();\n> >                         if (frames > 30)\n> > diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> > index ebf3e245f86b..852b853fa81a 100644\n> > --- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> > +++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> > @@ -19,8 +19,9 @@\n> >\n> >  #include \"test.h\"\n> >\n> > -using namespace std;\n> >  using namespace libcamera;\n> > +using namespace std;\n> > +using namespace std::chrono_literals;\n> >\n> >  class V4L2M2MDeviceTest : public Test\n> >  {\n> > @@ -155,7 +156,7 @@ protected:\n> >                 }\n> >\n> >                 Timer timeout;\n> > -               timeout.start(5000);\n> > +               timeout.start(5000ms);\n> >                 while (timeout.isRunning()) {\n> >                         dispatcher->processEvents();\n> >                         if (captureFrames_ > 30)\n> >\n> > base-commit: a8284e3570de133960458c5703e75dc9e8e737c8\n> > --\n> > Regards,\n> >\n> > Laurent Pinchart\n> >\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B590DBD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Mar 2022 07:13:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 10FFB604D5;\n\tWed, 23 Mar 2022 08:13:07 +0100 (CET)","from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com\n\t[IPv6:2a00:1450:4864:20::22a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 71918604C3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Mar 2022 08:13:05 +0100 (CET)","by mail-lj1-x22a.google.com with SMTP id q5so621481ljb.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Mar 2022 00:13:05 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648019587;\n\tbh=l2MNcB54JCTxnLLGmww7e6rPG+cYVeDjmdLh3Z7F6Pw=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Me88B8v/1A4IhAUVxtfYVwrREUTzyBUaY2momFPYAcBIVm/3aHLLP2IZfGyaUnHRS\n\tB2z8IjSLPr0caWjFjliMbnMn6ZBUpWZUPoD1d4eWNj2eyFhC2h7SLenv1tgqKHWgGL\n\tlOlXuGcBioFDHMGOsGs414YGVsDztS7g5lc6ykY1cRboy2X3HFdUVsyv1GPxi+Wt5H\n\tTt4ciUqiM5QfyfVY4cUw1OtDSkVM7KeYIQmA6Pyl7+CSKZ3mO8G1AApqeu6oj2iuu0\n\teCm4HU4wuDcHkhuhxQAkKiLQnUjOwbR4lIITVKxQ6ZxmZNNQsI6sLlk6zQmH2dT17K\n\tA3ezWzNuGxktw==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=7VfW+fP68r78D3yovVq82+0hMDkDBEQ2mrVNCnQHRZU=;\n\tb=DGweOip68BA7+6vAqUBfUTybpDf0DIzOY8KlqcPdvvBzQO1rBTfFC2PviblD8Up1Or\n\ti9iURFQRI3iM9IJEab6WoeBk4SGdYjZ/FHJurGvfHUczQxtfZdcVbpNhAD9dUHMCRAF7\n\tQFxvdRMtBVJPqM18Q8EC4RNM7PqKph16Snt+91qVNFwom6eB1i0Y4N9tpgcOBp83GN6W\n\tDUaV1f554gqeFrWa9iTmkdFAaMPuLtOfKr5dW9y89eWRXcRt2zcysSc9oLIG3gwq928q\n\t+n+qQr8PnguZCNkXJpC2NF4MwUuGmJ7s7NKoeQau6ruObpAfMzF1hNOpaGnWU0hjUlbI\n\t5DAA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"DGweOip6\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=7VfW+fP68r78D3yovVq82+0hMDkDBEQ2mrVNCnQHRZU=;\n\tb=ba1ydkOPl4tlwCC7I1Lm37P6iSv3nOKjM7nj+lIW9ewoq5cY5VPcsuZa7yeGUdx9IA\n\tYYF5OtAreW1T8hQQ1SKD8Dpu8DjCAzacyYdWfvePCRhwPg6c/k4Zg8lfkgTYY3NDiuF0\n\tm69aS4RlFDSpumcCOezMYLBisnUJ45BOJkHRZAuMBjwaHcDwI1ME1vWBKmHSw/jmnL69\n\tFCEVcivb0DT7XGf+xXkgSTExOzQbVjjv/HSSgK19rNKDDj/Umnysa2x/ob909ZqubCtx\n\tNgs6+lAsKAc0Mw71mKAag5v+5zxOFL/FCGDhg32kJ0yR4AK299jP6jXQrWjF7HWwwCU+\n\tmW9Q==","X-Gm-Message-State":"AOAM530UlaDC3LPl25KOeXL4iOmiFNxI+hjrOOecirIoOflejRUfnm6X\n\t5T0BJWCBWpMynNlRwpOgR9pt2sEt+lyO8JVNwVKQ3kRJ0yU=","X-Google-Smtp-Source":"ABdhPJx+mgBJTOB+B/ej0pDUrvNn8pa9xZr+J7X9535tuFTRofz+rQ4BGchL46STuzTTc57jPcSZ+/0T4xXbuBnYPJk=","X-Received":"by 2002:a2e:9d83:0:b0:246:2c6:79df with SMTP id\n\tc3-20020a2e9d83000000b0024602c679dfmr20879663ljj.280.1648019584475;\n\tWed, 23 Mar 2022 00:13:04 -0700 (PDT)","MIME-Version":"1.0","References":"<20220322204248.9226-1-laurent.pinchart@ideasonboard.com>\n\t<164798935424.506124.5289342867167838003@Monstersaurus>","In-Reply-To":"<164798935424.506124.5289342867167838003@Monstersaurus>","Date":"Wed, 23 Mar 2022 07:12:48 +0000","Message-ID":"<CAEmqJPqeGhYqa1ukMR8+4RMbZDX_DShHJZZO+x93VmtYg6GF3Q@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"000000000000ea7e6e05dadd758d\"","Subject":"Re: [libcamera-devel] [PATCH] libcamera: base: timer: Drop start()\n\toverload with int argument","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22384,"web_url":"https://patchwork.libcamera.org/comment/22384/","msgid":"<YjrcykBOHU+dpW7q@pendragon.ideasonboard.com>","date":"2022-03-23T08:39:38","subject":"Re: [libcamera-devel] [PATCH] libcamera: base: timer: Drop start()\n\toverload with int argument","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nOn Wed, Mar 23, 2022 at 07:12:48AM +0000, Naushir Patuck wrote:\n> On Tue, 22 Mar 2022 at 22:49, Kieran Bingham via libcamera-devel wrote:\n> > Quoting Laurent Pinchart via libcamera-devel (2022-03-22 20:42:48)\n> > > The start(unsigned int msec) overload is error-prone, as the argument\n> > > unit can easily be mistaken in callers. Drop it and update all callers\n> > > to use the start(std::chrono::milliseconds) overload instead.\n> > >\n> > > The callers now need to use std::chrono_literals. The using statement\n> > > could be added to timer.h for convenience, but \"using\" is discouraged in\n> > > header files to avoid namespace pollution. Update the callers instead,\n> > > and while at it, sort the \"using\" statements alphabetically in tests.\n> > >\n> >\n> > Does a utils::Duration implicitly get cast/converted to a\n> > std::chrono::milliseconds() with this now?\n> >\n> \n> Annoyingly not, as the utils::Duration base type is a double, and\n> std::chrono::milliseconds uses an integer.  So you need to explicitly\n> do a std::chrono::duration_cast<>.  We could consider switching the\n> utils::Duration base type to an integer as well (something we had talked\n> about in the past), I very much doubt double precision is absolutely\n> necessary.\n\ndouble precision in nanoseconds seems indeed a tad overkill :-)\n\n> > I.e. - does this help ease Naush's patches to accept a utils::duration?\n> > (Which is a good-thing-tm I think)\n> \n> I think Laurent's intention is to move utils::Duration to the public interface,\n> so we may not be able to use utils::Duration in the Timer class.  That is\n> not a big issue for me, but I'll reply to that thread separately.\n\nThank you.\n\n> > Anyway, I have a lot of fondness for chrono-literals. I think they\n> > really help improve readability, and I expect prevent bugs.\n> >\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> >\n> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > >  include/libcamera/base/timer.h           |  1 -\n> > >  src/libcamera/base/timer.cpp             | 10 --------\n> > >  src/libcamera/ipc_pipe_unixsocket.cpp    |  4 ++-\n> > >  test/camera/buffer_import.cpp            |  3 ++-\n> > >  test/camera/camera_reconfigure.cpp       |  3 ++-\n> > >  test/camera/capture.cpp                  |  3 ++-\n> > >  test/event-dispatcher.cpp                |  9 ++++---\n> > >  test/event.cpp                           | 11 +++++----\n> > >  test/fence.cpp                           |  6 ++---\n> > >  test/hotplug-cameras.cpp                 |  5 ++--\n> > >  test/ipa/ipa_interface_test.cpp          |  9 ++++---\n> > >  test/ipc/unixsocket.cpp                  |  5 ++--\n> > >  test/log/log_process.cpp                 |  5 ++--\n> > >  test/process/process_test.cpp            |  5 ++--\n> > >  test/timer-thread.cpp                    |  7 +++---\n> > >  test/timer.cpp                           | 31 ++++++++++++------------\n> > >  test/v4l2_videodevice/buffer_sharing.cpp |  3 ++-\n> > >  test/v4l2_videodevice/capture_async.cpp  |  3 ++-\n> > >  test/v4l2_videodevice/v4l2_m2mdevice.cpp |  5 ++--\n> > >  19 files changed, 67 insertions(+), 61 deletions(-)\n> > >\n> > > diff --git a/include/libcamera/base/timer.h b/include/libcamera/base/timer.h\n> > > index 09f1d3229bd5..759b68ada1e8 100644\n> > > --- a/include/libcamera/base/timer.h\n> > > +++ b/include/libcamera/base/timer.h\n> > > @@ -25,7 +25,6 @@ public:\n> > >         Timer(Object *parent = nullptr);\n> > >         ~Timer();\n> > >\n> > > -       void start(unsigned int msec) { start(std::chrono::milliseconds(msec)); }\n> > >         void start(std::chrono::milliseconds duration);\n> > >         void start(std::chrono::steady_clock::time_point deadline);\n> > >         void stop();\n> > > diff --git a/src/libcamera/base/timer.cpp b/src/libcamera/base/timer.cpp\n> > > index 187336e3a1a4..74b060af32ff 100644\n> > > --- a/src/libcamera/base/timer.cpp\n> > > +++ b/src/libcamera/base/timer.cpp\n> > > @@ -62,16 +62,6 @@ Timer::~Timer()\n> > >         stop();\n> > >  }\n> > >\n> > > -/**\n> > > - * \\fn Timer::start(unsigned int msec)\n> > > - * \\brief Start or restart the timer with a timeout of \\a msec\n> > > - * \\param[in] msec The timer duration in milliseconds\n> > > - *\n> > > - * If the timer is already running it will be stopped and restarted.\n> > > - *\n> > > - * \\context This function is \\threadbound.\n> > > - */\n> > > -\n> > >  /**\n> > >   * \\brief Start or restart the timer with a timeout of \\a duration\n> > >   * \\param[in] duration The timer duration in milliseconds\n> > > diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp\n> > > index 3ef907090131..da2cffc3b149 100644\n> > > --- a/src/libcamera/ipc_pipe_unixsocket.cpp\n> > > +++ b/src/libcamera/ipc_pipe_unixsocket.cpp\n> > > @@ -18,6 +18,8 @@\n> > >  #include \"libcamera/internal/ipc_unixsocket.h\"\n> > >  #include \"libcamera/internal/process.h\"\n> > >\n> > > +using namespace std::chrono_literals;\n> > > +\n> > >  namespace libcamera {\n> > >\n> > >  LOG_DECLARE_CATEGORY(IPCPipe)\n> > > @@ -126,7 +128,7 @@ int IPCPipeUnixSocket::call(const IPCUnixSocket::Payload &message,\n> > >         }\n> > >\n> > >         /* \\todo Make this less dangerous, see IPCPipe::sendSync() */\n> > > -       timeout.start(2000);\n> > > +       timeout.start(2000ms);\n> > >         while (!iter->second.done) {\n> > >                 if (!timeout.isRunning()) {\n> > >                         LOG(IPCPipe, Error) << \"Call timeout!\";\n> > > diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\n> > > index c504ea09e64b..9288400474a7 100644\n> > > --- a/test/camera/buffer_import.cpp\n> > > +++ b/test/camera/buffer_import.cpp\n> > > @@ -25,6 +25,7 @@\n> > >  #include \"test.h\"\n> > >\n> > >  using namespace libcamera;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  namespace {\n> > >\n> > > @@ -135,7 +136,7 @@ protected:\n> > >                 EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n> > >\n> > >                 Timer timer;\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >                 while (timer.isRunning())\n> > >                         dispatcher->processEvents();\n> > >\n> > > diff --git a/test/camera/camera_reconfigure.cpp b/test/camera/camera_reconfigure.cpp\n> > > index 0fd8ab70d561..f6076baa0a31 100644\n> > > --- a/test/camera/camera_reconfigure.cpp\n> > > +++ b/test/camera/camera_reconfigure.cpp\n> > > @@ -23,6 +23,7 @@\n> > >\n> > >  using namespace libcamera;\n> > >  using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  namespace {\n> > >\n> > > @@ -117,7 +118,7 @@ private:\n> > >                 EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n> > >\n> > >                 Timer timer;\n> > > -               timer.start(100);\n> > > +               timer.start(100ms);\n> > >                 while (timer.isRunning())\n> > >                         dispatcher->processEvents();\n> > >\n> > > diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> > > index f3824f95cbd3..de824083dfed 100644\n> > > --- a/test/camera/capture.cpp\n> > > +++ b/test/camera/capture.cpp\n> > > @@ -18,6 +18,7 @@\n> > >\n> > >  using namespace libcamera;\n> > >  using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  namespace {\n> > >\n> > > @@ -137,7 +138,7 @@ protected:\n> > >                 EventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n> > >\n> > >                 Timer timer;\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >                 while (timer.isRunning())\n> > >                         dispatcher->processEvents();\n> > >\n> > > diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp\n> > > index 1cc17b045ec0..9b07ab2b61d7 100644\n> > > --- a/test/event-dispatcher.cpp\n> > > +++ b/test/event-dispatcher.cpp\n> > > @@ -16,8 +16,9 @@\n> > >\n> > >  #include \"test.h\"\n> > >\n> > > -using namespace std;\n> > >  using namespace libcamera;\n> > > +using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  static EventDispatcher *dispatcher;\n> > >  static bool interrupt;\n> > > @@ -50,7 +51,7 @@ protected:\n> > >                 /* Event processing interruption by signal. */\n> > >                 std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();\n> > >\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >\n> > >                 struct itimerval itimer = {};\n> > >                 itimer.it_value.tv_usec = 500000;\n> > > @@ -69,7 +70,7 @@ protected:\n> > >                 }\n> > >\n> > >                 /* Event processing interruption. */\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >                 dispatcher->interrupt();\n> > >\n> > >                 dispatcher->processEvents();\n> > > @@ -79,7 +80,7 @@ protected:\n> > >                         return TestFail;\n> > >                 }\n> > >\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >                 itimer.it_value.tv_usec = 500000;\n> > >                 interrupt = true;\n> > >                 setitimer(ITIMER_REAL, &itimer, nullptr);\n> > > diff --git a/test/event.cpp b/test/event.cpp\n> > > index d4765eb14d12..19dceae123dd 100644\n> > > --- a/test/event.cpp\n> > > +++ b/test/event.cpp\n> > > @@ -16,8 +16,9 @@\n> > >\n> > >  #include \"test.h\"\n> > >\n> > > -using namespace std;\n> > >  using namespace libcamera;\n> > > +using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  class EventTest : public Test\n> > >  {\n> > > @@ -55,7 +56,7 @@ protected:\n> > >                         return TestFail;\n> > >                 }\n> > >\n> > > -               timeout.start(100);\n> > > +               timeout.start(100ms);\n> > >                 dispatcher->processEvents();\n> > >                 timeout.stop();\n> > >\n> > > @@ -67,7 +68,7 @@ protected:\n> > >                 /* Test read notification without data. */\n> > >                 notified_ = false;\n> > >\n> > > -               timeout.start(100);\n> > > +               timeout.start(100ms);\n> > >                 dispatcher->processEvents();\n> > >                 timeout.stop();\n> > >\n> > > @@ -86,7 +87,7 @@ protected:\n> > >                         return TestFail;\n> > >                 }\n> > >\n> > > -               timeout.start(100);\n> > > +               timeout.start(100ms);\n> > >                 dispatcher->processEvents();\n> > >                 timeout.stop();\n> > >\n> > > @@ -99,7 +100,7 @@ protected:\n> > >                 notified_ = false;\n> > >                 notifier_->setEnabled(true);\n> > >\n> > > -               timeout.start(100);\n> > > +               timeout.start(100ms);\n> > >                 dispatcher->processEvents();\n> > >                 timeout.stop();\n> > >\n> > > diff --git a/test/fence.cpp b/test/fence.cpp\n> > > index 524db2a10757..1e38bc2f8790 100644\n> > > --- a/test/fence.cpp\n> > > +++ b/test/fence.cpp\n> > > @@ -22,9 +22,9 @@\n> > >  #include \"camera_test.h\"\n> > >  #include \"test.h\"\n> > >\n> > > -using namespace std::chrono_literals;\n> > >  using namespace libcamera;\n> > >  using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  class FenceTest : public CameraTest, public Test\n> > >  {\n> > > @@ -316,7 +316,7 @@ int FenceTest::run()\n> > >\n> > >         /* Loop for one second. */\n> > >         Timer timer;\n> > > -       timer.start(1000);\n> > > +       timer.start(1000ms);\n> > >         while (timer.isRunning() && expectedCompletionResult_) {\n> > >                 if (completedRequest_ == signalledRequestId_ && setFence_)\n> > >                         /*\n> > > @@ -324,7 +324,7 @@ int FenceTest::run()\n> > >                          * been re-queued with a fence. Start the timer to\n> > >                          * signal the fence in 10 msec.\n> > >                          */\n> > > -                       fenceTimer.start(10);\n> > > +                       fenceTimer.start(10ms);\n> > >\n> > >                 dispatcher_->processEvents();\n> > >         }\n> > > diff --git a/test/hotplug-cameras.cpp b/test/hotplug-cameras.cpp\n> > > index df56040350c5..5d9260a241ec 100644\n> > > --- a/test/hotplug-cameras.cpp\n> > > +++ b/test/hotplug-cameras.cpp\n> > > @@ -22,6 +22,7 @@\n> > >  #include \"test.h\"\n> > >\n> > >  using namespace libcamera;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  class HotplugTest : public Test\n> > >  {\n> > > @@ -88,7 +89,7 @@ protected:\n> > >                 std::ofstream(uvcDriverDir_ + \"unbind\", std::ios::binary)\n> > >                         << uvcDeviceDir;\n> > >                 Timer timer;\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >                 while (timer.isRunning() && !cameraRemoved_)\n> > >  Thread::current()->eventDispatcher()->processEvents();\n> > >                 if (!cameraRemoved_) {\n> > > @@ -99,7 +100,7 @@ protected:\n> > >                 /* Bind the camera again and process events. */\n> > >                 std::ofstream(uvcDriverDir_ + \"bind\", std::ios::binary)\n> > >                         << uvcDeviceDir;\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >                 while (timer.isRunning() && !cameraAdded_)\n> > >  Thread::current()->eventDispatcher()->processEvents();\n> > >                 if (!cameraAdded_) {\n> > > diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\n> > > index 43562e608506..3c0df843ea61 100644\n> > > --- a/test/ipa/ipa_interface_test.cpp\n> > > +++ b/test/ipa/ipa_interface_test.cpp\n> > > @@ -27,8 +27,9 @@\n> > >\n> > >  #include \"test.h\"\n> > >\n> > > -using namespace std;\n> > >  using namespace libcamera;\n> > > +using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  class IPAInterfaceTest : public Test, public Object\n> > >  {\n> > > @@ -111,7 +112,7 @@ protected:\n> > >                         return TestFail;\n> > >                 }\n> > >\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >                 while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationInit)\n> > >                         dispatcher->processEvents();\n> > >\n> > > @@ -123,7 +124,7 @@ protected:\n> > >\n> > >                 /* Test start of IPA module. */\n> > >                 ipa_->start();\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >                 while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationStart)\n> > >                         dispatcher->processEvents();\n> > >\n> > > @@ -134,7 +135,7 @@ protected:\n> > >\n> > >                 /* Test stop of IPA module. */\n> > >                 ipa_->stop();\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >                 while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationStop)\n> > >                         dispatcher->processEvents();\n> > >\n> > > diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp\n> > > index 7e90e629e9ac..304e613bc984 100644\n> > > --- a/test/ipc/unixsocket.cpp\n> > > +++ b/test/ipc/unixsocket.cpp\n> > > @@ -30,8 +30,9 @@\n> > >  #define CMD_LEN_CMP    3\n> > >  #define CMD_JOIN       4\n> > >\n> > > -using namespace std;\n> > >  using namespace libcamera;\n> > > +using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  int calculateLength(int fd)\n> > >  {\n> > > @@ -430,7 +431,7 @@ private:\n> > >                 if (ret)\n> > >                         return ret;\n> > >\n> > > -               timeout.start(200);\n> > > +               timeout.start(200ms);\n> > >                 while (!callDone_) {\n> > >                         if (!timeout.isRunning()) {\n> > >                                 cerr << \"Call timeout!\" << endl;\n> > > diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp\n> > > index 2484c58f2fa9..966b80cf3af7 100644\n> > > --- a/test/log/log_process.cpp\n> > > +++ b/test/log/log_process.cpp\n> > > @@ -26,8 +26,9 @@\n> > >\n> > >  #include \"test.h\"\n> > >\n> > > -using namespace std;\n> > >  using namespace libcamera;\n> > > +using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  static const string message(\"hello from the child\");\n> > >\n> > > @@ -80,7 +81,7 @@ protected:\n> > >                         return TestFail;\n> > >                 }\n> > >\n> > > -               timeout.start(200);\n> > > +               timeout.start(200ms);\n> > >                 while (timeout.isRunning())\n> > >                         dispatcher->processEvents();\n> > >\n> > > diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp\n> > > index b410756b3288..cb6940c6a7db 100644\n> > > --- a/test/process/process_test.cpp\n> > > +++ b/test/process/process_test.cpp\n> > > @@ -18,8 +18,9 @@\n> > >\n> > >  #include \"test.h\"\n> > >\n> > > -using namespace std;\n> > >  using namespace libcamera;\n> > > +using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  class ProcessTestChild\n> > >  {\n> > > @@ -61,7 +62,7 @@ protected:\n> > >                         return TestFail;\n> > >                 }\n> > >\n> > > -               timeout.start(2000);\n> > > +               timeout.start(2000ms);\n> > >                 while (timeout.isRunning() && exitStatus_ == Process::NotExited)\n> > >                         dispatcher->processEvents();\n> > >\n> > > diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp\n> > > index f7e8743da9e6..618217538779 100644\n> > > --- a/test/timer-thread.cpp\n> > > +++ b/test/timer-thread.cpp\n> > > @@ -14,8 +14,9 @@\n> > >\n> > >  #include \"test.h\"\n> > >\n> > > -using namespace std;\n> > >  using namespace libcamera;\n> > > +using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  class TimeoutHandler : public Object\n> > >  {\n> > > @@ -24,13 +25,13 @@ public:\n> > >                 : timer_(this), timeout_(false)\n> > >         {\n> > >                 timer_.timeout.connect(this, &TimeoutHandler::timeoutHandler);\n> > > -               timer_.start(100);\n> > > +               timer_.start(100ms);\n> > >         }\n> > >\n> > >         void restart()\n> > >         {\n> > >                 timeout_ = false;\n> > > -               timer_.start(100);\n> > > +               timer_.start(100ms);\n> > >         }\n> > >\n> > >         bool timeout() const\n> > > diff --git a/test/timer.cpp b/test/timer.cpp\n> > > index be79d0100a58..0f01c3cb00ea 100644\n> > > --- a/test/timer.cpp\n> > > +++ b/test/timer.cpp\n> > > @@ -14,8 +14,9 @@\n> > >\n> > >  #include \"test.h\"\n> > >\n> > > -using namespace std;\n> > >  using namespace libcamera;\n> > > +using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  class ManagedTimer : public Timer\n> > >  {\n> > > @@ -26,7 +27,7 @@ public:\n> > >                 timeout.connect(this, &ManagedTimer::timeoutHandler);\n> > >         }\n> > >\n> > > -       void start(int msec)\n> > > +       void start(std::chrono::milliseconds msec)\n> > >         {\n> > >                 count_ = 0;\n> > >                 start_ = std::chrono::steady_clock::now();\n> > > @@ -82,7 +83,7 @@ protected:\n> > >                 ManagedTimer timer2;\n> > >\n> > >                 /* Timer expiration. */\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >\n> > >                 if (!timer.isRunning()) {\n> > >                         cout << \"Timer expiration test failed\" << endl;\n> > > @@ -101,7 +102,7 @@ protected:\n> > >                  * Nanosecond resolution in a 32 bit value wraps at 4.294967\n> > >                  * seconds (0xFFFFFFFF / 1000000)\n> > >                  */\n> > > -               timer.start(4295);\n> > > +               timer.start(4295ms);\n> > >                 dispatcher->processEvents();\n> > >\n> > >                 if (timer.hasFailed()) {\n> > > @@ -110,7 +111,7 @@ protected:\n> > >                 }\n> > >\n> > >                 /* Timer restart. */\n> > > -               timer.start(500);\n> > > +               timer.start(500ms);\n> > >\n> > >                 if (!timer.isRunning()) {\n> > >                         cout << \"Timer restart test failed\" << endl;\n> > > @@ -125,9 +126,9 @@ protected:\n> > >                 }\n> > >\n> > >                 /* Timer restart before expiration. */\n> > > -               timer.start(50);\n> > > -               timer.start(100);\n> > > -               timer.start(150);\n> > > +               timer.start(50ms);\n> > > +               timer.start(100ms);\n> > > +               timer.start(150ms);\n> > >\n> > >                 dispatcher->processEvents();\n> > >\n> > > @@ -147,8 +148,8 @@ protected:\n> > >                 }\n> > >\n> > >                 /* Two timers. */\n> > > -               timer.start(1000);\n> > > -               timer2.start(300);\n> > > +               timer.start(1000ms);\n> > > +               timer2.start(300ms);\n> > >\n> > >                 dispatcher->processEvents();\n> > >\n> > > @@ -170,8 +171,8 @@ protected:\n> > >                 }\n> > >\n> > >                 /* Restart timer before expiration. */\n> > > -               timer.start(1000);\n> > > -               timer2.start(300);\n> > > +               timer.start(1000ms);\n> > > +               timer2.start(300ms);\n> > >\n> > >                 dispatcher->processEvents();\n> > >\n> > > @@ -180,7 +181,7 @@ protected:\n> > >                         return TestFail;\n> > >                 }\n> > >\n> > > -               timer.start(1000);\n> > > +               timer.start(1000ms);\n> > >\n> > >                 dispatcher->processEvents();\n> > >\n> > > @@ -194,10 +195,10 @@ protected:\n> > >                  * deleted. This will result in a crash on failure.\n> > >                  */\n> > >                 ManagedTimer *dyntimer = new ManagedTimer();\n> > > -               dyntimer->start(100);\n> > > +               dyntimer->start(100ms);\n> > >                 delete dyntimer;\n> > >\n> > > -               timer.start(200);\n> > > +               timer.start(200ms);\n> > >                 dispatcher->processEvents();\n> > >\n> > >                 return TestPass;\n> > > diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp\n> > > index 75ee93ce5261..fa856ab6b5a8 100644\n> > > --- a/test/v4l2_videodevice/buffer_sharing.cpp\n> > > +++ b/test/v4l2_videodevice/buffer_sharing.cpp\n> > > @@ -21,6 +21,7 @@\n> > >  #include \"v4l2_videodevice_test.h\"\n> > >\n> > >  using namespace libcamera;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  class BufferSharingTest : public V4L2VideoDeviceTest\n> > >  {\n> > > @@ -145,7 +146,7 @@ protected:\n> > >                         return TestFail;\n> > >                 }\n> > >\n> > > -               timeout.start(10000);\n> > > +               timeout.start(10000ms);\n> > >                 while (timeout.isRunning()) {\n> > >                         dispatcher->processEvents();\n> > >                         if (framesCaptured_ > 30 && framesOutput_ > 30)\n> > > diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp\n> > > index 3aa4ca0b6955..42e1e671790b 100644\n> > > --- a/test/v4l2_videodevice/capture_async.cpp\n> > > +++ b/test/v4l2_videodevice/capture_async.cpp\n> > > @@ -16,6 +16,7 @@\n> > >  #include \"v4l2_videodevice_test.h\"\n> > >\n> > >  using namespace libcamera;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  class CaptureAsyncTest : public V4L2VideoDeviceTest\n> > >  {\n> > > @@ -60,7 +61,7 @@ protected:\n> > >                 if (ret)\n> > >                         return TestFail;\n> > >\n> > > -               timeout.start(10000);\n> > > +               timeout.start(10000ms);\n> > >                 while (timeout.isRunning()) {\n> > >                         dispatcher->processEvents();\n> > >                         if (frames > 30)\n> > > diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> > > index ebf3e245f86b..852b853fa81a 100644\n> > > --- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> > > +++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n> > > @@ -19,8 +19,9 @@\n> > >\n> > >  #include \"test.h\"\n> > >\n> > > -using namespace std;\n> > >  using namespace libcamera;\n> > > +using namespace std;\n> > > +using namespace std::chrono_literals;\n> > >\n> > >  class V4L2M2MDeviceTest : public Test\n> > >  {\n> > > @@ -155,7 +156,7 @@ protected:\n> > >                 }\n> > >\n> > >                 Timer timeout;\n> > > -               timeout.start(5000);\n> > > +               timeout.start(5000ms);\n> > >                 while (timeout.isRunning()) {\n> > >                         dispatcher->processEvents();\n> > >                         if (captureFrames_ > 30)\n> > >\n> > > base-commit: a8284e3570de133960458c5703e75dc9e8e737c8","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E38A2C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Mar 2022 08:39:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1D12A604C6;\n\tWed, 23 Mar 2022 09:39:58 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 87DC2601F8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Mar 2022 09:39:56 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E256F9DE;\n\tWed, 23 Mar 2022 09:39:55 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648024798;\n\tbh=s8Y+8Wcz6tVjDDzoUQyjAnZi8zZo++58K3WTuL2xOPY=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=f1fib0d/DkkvpDfzgh3E+ngc97Fis5xTM1bLvxdXbx1MnIhM9BpcnFKfOhvPfmXMP\n\te1EGN3QfFCGlem0R64bVNs5+x0UWE6bAIluvlTrVqncfj7kYXy+UueKDcsS1TKTiwR\n\tbI20eAv/xxFx4uPL7Ipmu0QNqn3jI4PVRPfODDe1egCunnhCRwgDUI5E3DQ556RMPw\n\tB9wTRgD13dBjGjg8seYvNRv0HbhFl8OuPhKAc+X9kk8qo8kOrxhoYaCvcBtWck57Ya\n\to1taKnxPCqRbhFlStDZZOAdIO5S8fQWRMl96ky9Rm93nUdNUdthOI275LrruLOpzkJ\n\tYVyPw+J014lkQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1648024796;\n\tbh=s8Y+8Wcz6tVjDDzoUQyjAnZi8zZo++58K3WTuL2xOPY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=CNzy13NDnezuq8pXYQ9ffJ10bRwwfzJJPNJl7ZvZFJag2eBJ5ZeiX9DbFTOH2bHne\n\toQrqlkhJ8QQ6Vq1+d7nrdt3F3cxA8giup9TddX0FaaS6cz02VZgmoZZth98N5twLHY\n\tgHspyFZZ/H9cq+nTRDNwabzwuXM5+B1/M5csr8SA="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"CNzy13ND\"; dkim-atps=neutral","Date":"Wed, 23 Mar 2022 10:39:38 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YjrcykBOHU+dpW7q@pendragon.ideasonboard.com>","References":"<20220322204248.9226-1-laurent.pinchart@ideasonboard.com>\n\t<164798935424.506124.5289342867167838003@Monstersaurus>\n\t<CAEmqJPqeGhYqa1ukMR8+4RMbZDX_DShHJZZO+x93VmtYg6GF3Q@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAEmqJPqeGhYqa1ukMR8+4RMbZDX_DShHJZZO+x93VmtYg6GF3Q@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: base: timer: Drop start()\n\toverload with int argument","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]