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


C++ EventPublisherRef::hasStarted方法代码示例

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


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

示例1: run

Status EventFactory::run(EventPublisherID& type_id) {
  if (FLAGS_disable_events) {
    return Status(0, "Events disabled");
  }

  // An interesting take on an event dispatched entrypoint.
  // There is little introspection into the event type.
  // Assume it can either make use of an entrypoint poller/selector or
  // take care of async callback registrations in setUp/configure/run
  // only once and handle event queuing/firing in callbacks.
  EventPublisherRef publisher = nullptr;
  {
    auto& ef = EventFactory::getInstance();
    WriteLock lock(getInstance().factory_lock_);
    publisher = ef.getEventPublisher(type_id);
  }

  if (publisher == nullptr) {
    return Status(1, "Event publisher is missing");
  } else if (publisher->hasStarted()) {
    return Status(1, "Cannot restart an event publisher");
  }
  VLOG(1) << "Starting event publisher run loop: " + type_id;
  publisher->hasStarted(true);

  auto status = Status(0, "OK");
  while (!publisher->isEnding()) {
    // Can optionally implement a global cooloff latency here.
    status = publisher->run();
    if (!status.ok()) {
      break;
    }
    publisher->restart_count_++;
    // This is a 'default' cool-off implemented in InterruptableRunnable.
    // If a publisher fails to perform some sort of interruption point, this
    // prevents the thread from thrashing through exiting checks.
    publisher->pause();
  }
  if (!status.ok()) {
    // The runloop status is not reflective of the event type's.
    VLOG(1) << "Event publisher " << publisher->type()
            << " run loop terminated for reason: " << status.getMessage();
    // Publishers auto tear down when their run loop stops.
  }
  publisher->tearDown();

  // Do not remove the publisher from the event factory.
  // If the event factory's `end` method was called these publishers will be
  // cleaned up after their thread context is removed; otherwise, a removed
  // thread context and failed publisher will remain available for stats.
  return Status(0, "OK");
}
开发者ID:GarfieldIsAPhilosopher,项目名称:osquery,代码行数:52,代码来源:events.cpp

示例2: deregisterEventPublisher

Status EventFactory::deregisterEventPublisher(EventPublisherID& type_id) {
  auto& ef = EventFactory::getInstance();
  EventPublisherRef publisher;
  try {
    publisher = ef.getEventPublisher(type_id);
  } catch (std::out_of_range& e) {
    return Status(1, "No event publisher to deregister");
  }

  if (!FLAGS_disable_events) {
    publisher->isEnding(true);
    if (!publisher->hasStarted()) {
      // If a publisher's run loop was not started, call tearDown since
      // the setUp happened at publisher registration time.
      publisher->tearDown();
      // If the run loop did run the tear down and erase will happen in the
      // event
      // thread wrapper when isEnding is next checked.
      ef.event_pubs_.erase(type_id);
    } else {
      publisher->end();
    }
  }
  return Status(0, "OK");
}
开发者ID:eastebry,项目名称:osquery,代码行数:25,代码来源:events.cpp

示例3: run

Status EventFactory::run(EventPublisherID& type_id) {
  // An interesting take on an event dispatched entrypoint.
  // There is little introspection into the event type.
  // Assume it can either make use of an entrypoint poller/selector or
  // take care of async callback registrations in setUp/configure/run
  // only once and handle event queueing/firing in callbacks.
  EventPublisherRef publisher;
  try {
    publisher = EventFactory::getInstance().getEventPublisher(type_id);
  } catch (std::out_of_range& e) {
    return Status(1, "No event type found");
  }

  VLOG(1) << "Starting event publisher runloop: " + type_id;
  publisher->hasStarted(true);

  auto status = Status(0, "OK");
  while (!publisher->isEnding() && status.ok()) {
    // Can optionally implement a global cooloff latency here.
    status = publisher->run();
    osquery::publisherSleep(EVENTS_COOLOFF);
  }

  // The runloop status is not reflective of the event type's.
  publisher->tearDown();
  VLOG(1) << "Event publisher " << publisher->type()
          << " runloop terminated for reason: " << status.getMessage();
  return Status(0, "OK");
}
开发者ID:JessicaWhite17,项目名称:osquery,代码行数:29,代码来源:events.cpp

示例4: run

Status EventFactory::run(EventPublisherID& type_id) {
  auto& ef = EventFactory::getInstance();
  if (FLAGS_disable_events) {
    return Status(0, "Events disabled");
  }

  // An interesting take on an event dispatched entrypoint.
  // There is little introspection into the event type.
  // Assume it can either make use of an entrypoint poller/selector or
  // take care of async callback registrations in setUp/configure/run
  // only once and handle event queuing/firing in callbacks.
  EventPublisherRef publisher = ef.getEventPublisher(type_id);

  if (publisher == nullptr) {
    return Status(1, "Event publisher is missing");
  } else if (publisher->hasStarted()) {
    return Status(1, "Cannot restart an event publisher");
  }
  VLOG(1) << "Starting event publisher run loop: " + type_id;
  publisher->hasStarted(true);

  auto status = Status(0, "OK");
  while (!publisher->isEnding() && status.ok()) {
    // Can optionally implement a global cooloff latency here.
    status = publisher->run();
    publisher->restart_count_++;
    osquery::publisherSleep(EVENTS_COOLOFF);
  }
  // The runloop status is not reflective of the event type's.
  VLOG(1) << "Event publisher " << publisher->type()
          << " run loop terminated for reason: " << status.getMessage();
  // Publishers auto tear down when their run loop stops.
  publisher->tearDown();

  // Do not remove the publisher from the event factory.
  // If the event factory's `end` method was called these publishers will be
  // cleaned up after their thread context is removed; otherwise, a removed
  // thread context and failed publisher will remain available for stats.
  // ef.event_pubs_.erase(type_id);
  return Status(0, "OK");
}
开发者ID:erdincay,项目名称:osquery,代码行数:41,代码来源:events.cpp

示例5: deregisterEventPublisher

Status EventFactory::deregisterEventPublisher(EventPublisherID& type_id) {
  auto& ef = EventFactory::getInstance();
  EventPublisherRef publisher;
  try {
    publisher = ef.getEventPublisher(type_id);
  } catch (std::out_of_range& e) {
    return Status(1, "No event publisher to deregister");
  }

  publisher->isEnding(true);
  if (!publisher->hasStarted()) {
    // If a publisher's run loop was not started, call tearDown since
    // the setUp happened at publisher registration time.
    publisher->tearDown();
  }

  ef.event_pubs_.erase(type_id);
  return Status(0, "OK");
}
开发者ID:JessicaWhite17,项目名称:osquery,代码行数:19,代码来源:events.cpp


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