当前位置: 首页>>代码示例>>C++>>正文


C++ Duration::secs方法代码示例

本文整理汇总了C++中Duration::secs方法的典型用法代码示例。如果您正苦于以下问题:C++ Duration::secs方法的具体用法?C++ Duration::secs怎么用?C++ Duration::secs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Duration的用法示例。


在下文中一共展示了Duration::secs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LOG

void V0ToV1AdapterProcess::registered(
    const FrameworkID& _frameworkId,
    const MasterInfo& masterInfo)
{
  LOG(INFO) << "Registered with the Mesos master; invoking connected callback";

  connect();

  // We need this copy to populate the fields in `Event::Subscribed` upon
  // receiving a `reregistered()` callback later.
  frameworkId = _frameworkId;

  // These events are queued and delivered to the scheduler upon receiving the
  // subscribe call later. See comments in `send()` for more details.
  {
    Event event;
    event.set_type(Event::SUBSCRIBED);

    Event::Subscribed* subscribed = event.mutable_subscribed();

    subscribed->mutable_framework_id()->CopyFrom(evolve(frameworkId.get()));
    subscribed->set_heartbeat_interval_seconds(interval.secs());
    subscribed->mutable_master_info()->CopyFrom(evolve(masterInfo));

    received(event);
  }

  {
    Event event;
    event.set_type(Event::HEARTBEAT);

    received(event);
  }
}
开发者ID:ederst,项目名称:mesos,代码行数:34,代码来源:org_apache_mesos_v1_scheduler_V0Mesos.cpp

示例2: generate

  void generate()
  {
    watch.start();

    while (true) {
      Duration elapsed = watch.elapsed();

      if (duration.isSome() && elapsed >= duration.get()) {
        LOG(INFO) << "LoadGenerator generated " << messages
                  << " messages in " << elapsed << " (throughput = "
                  << (messages / elapsed.secs()) << " messages/sec)";

        LOG(INFO) << "Stopping LoadGenerator and scheduler driver";

        terminate(self());
        driver->stop();
        return;
      }

      Stopwatch reconcile;
      reconcile.start();

      driver->reconcileTasks(vector<TaskStatus>());

      messages++;

      // Compensate for the driver call overhead.
      os::sleep(std::max(
          Duration::zero(),
          Seconds(1) / qps - reconcile.elapsed()));
    }
  }
开发者ID:GrovoLearning,项目名称:mesos,代码行数:32,代码来源:load_generator_framework.cpp

示例3:

TEST(Time, timestamp) {

    Time t;
    
    ASSERT_FALSE(t);
    
    t = Time::now();
    
    ASSERT_TRUE(t);
    
    Time t2 = t + Duration::mins(1);
    Duration d = t2-t;
    
    ASSERT_EQ(60, d.secs());
}
开发者ID:respu,项目名称:mvcgame,代码行数:15,代码来源:TimeTest.cpp

示例4: command

string command(
    const set<string>& events,
    const set<pid_t>& pids,
    const Duration& duration)
{
  ostringstream command;

  command << "perf stat -x" << PERF_DELIMITER << " -a";
  command << " --log-fd 1";  // Ensure all output goes to stdout.
  command << " --event " << strings::join(",", events);
  command << " --pid " << strings::join(",", pids);
  command << " -- sleep " << stringify(duration.secs());

  return command.str();
}
开发者ID:Benguang,项目名称:mesos,代码行数:15,代码来源:perf.cpp

示例5: ErrnoError

// Suspends execution for the given duration.
inline Try<Nothing> sleep(const Duration& duration)
{
  timespec remaining;
  remaining.tv_sec = static_cast<long>(duration.secs());
  remaining.tv_nsec =
    static_cast<long>((duration - Seconds(remaining.tv_sec)).ns());

  while (nanosleep(&remaining, &remaining) == -1) {
    if (errno == EINTR) {
      continue;
    } else {
      return ErrnoError();
    }
  }

  return Nothing();
}
开发者ID:OvertimeDog,项目名称:mesos,代码行数:18,代码来源:os.hpp

示例6: if

inline std::ostream& operator<<(std::ostream& stream, const Duration& duration_)
{
  // Output the duration in full double precision and save the old precision.
  std::streamsize precision =
    stream.precision(std::numeric_limits<double>::digits10);

  // Parse the duration as the sign and the absolute value.
  Duration duration = duration_;
  if (duration_ < Duration::zero()) {
    stream << "-";

    // Duration::min() may not be representable as a positive Duration.
    if (duration_ == Duration::min()) {
      duration = Duration::max();
    } else {
      duration = duration_ * -1;
    }
  }

  // First determine which bucket of time unit the duration falls into
  // then check whether the duration can be represented as a whole
  // number with this time unit or a smaller one.
  // e.g. 1.42857142857143weeks falls into the 'Weeks' bucket but
  // reads better with a smaller unit: '10days'. So we use 'days'
  // instead of 'weeks' to output the duration.
  int64_t nanoseconds = duration.ns();
  if (duration < Microseconds(1)) {
    stream << duration.ns() << Nanoseconds::units();
  } else if (duration < Milliseconds(1)) {
    if (nanoseconds % Duration::MICROSECONDS != 0) {
      // We can't get a whole number using this unit but we can at
      // one level down.
      stream << duration.ns() << Nanoseconds::units();
    } else {
      stream << duration.us() << Microseconds::units();
    }
  } else if (duration < Seconds(1)) {
    if (nanoseconds % Duration::MILLISECONDS != 0 &&
        nanoseconds % Duration::MICROSECONDS == 0) {
      stream << duration.us() << Microseconds::units();
    } else {
      stream << duration.ms() << Milliseconds::units();
    }
  } else if (duration < Minutes(1)) {
    if (nanoseconds % Duration::SECONDS != 0 &&
        nanoseconds % Duration::MILLISECONDS == 0) {
      stream << duration.ms() << Milliseconds::units();
    } else {
      stream << duration.secs() << Seconds::units();
    }
  } else if (duration < Hours(1)) {
    if (nanoseconds % Duration::MINUTES != 0 &&
        nanoseconds % Duration::SECONDS == 0) {
      stream << duration.secs() << Seconds::units();
    } else {
      stream << duration.mins() << Minutes::units();
    }
  } else if (duration < Days(1)) {
    if (nanoseconds % Duration::HOURS != 0 &&
        nanoseconds % Duration::MINUTES == 0) {
      stream << duration.mins() << Minutes::units();
    } else {
      stream << duration.hrs() << Hours::units();
    }
  } else if (duration < Weeks(1)) {
    if (nanoseconds % Duration::DAYS != 0 &&
        nanoseconds % Duration::HOURS == 0) {
      stream << duration.hrs() << Hours::units();
    } else {
      stream << duration.days() << Days::units();
    }
  } else {
    if (nanoseconds % Duration::WEEKS != 0 &&
        nanoseconds % Duration::DAYS == 0) {
      stream << duration.days() << Days::units();
    } else {
      stream << duration.weeks() << Weeks::units();
    }
  }

  // Return the stream to original formatting state.
  stream.precision(precision);

  return stream;
}
开发者ID:wzqtony,项目名称:mesos,代码行数:85,代码来源:duration.hpp


注:本文中的Duration::secs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。