Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-51168

Modernise GlobalTask::snooze

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Major
    • Morpheus
    • None
    • couchbase-bucket
    • 1

    Description

      Snoozing a global task currently takes a double of seconds

      GlobalTask::snooze(const double secs) 
      

      and internally compares to INT_MAX, to indicate "sleep forever".

          if (secs == INT_MAX) {
              setState(TASK_SNOOZED, TASK_RUNNING);
              updateWaketime(std::chrono::steady_clock::time_point::max());
              return;
          }
      

      Therefore, many callers provide INT_MAX or std::numeric_limits<int>::max(), which is converted to a double, then compared against an int.

      This leaves the possibility of typos (e.g., UINT_MAX, std::numeric_limits<size_t>::max()), and requires the caller to handle the units (seconds vs milliseconds etc).

      The interface could be improved with by taking a duration, e.g.,

      GlobalTask::snooze(std::chrono::steady_clock::duration sleepTime)
      

      Attachments

        For Gerrit Dashboard: MB-51168
        # Subject Branch Project Status CR V

        Activity

          People

            hareen.kancharla Hareen Kancharla
            james.harrison James Harrison (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              PagerDuty