Exemplo n.º 1
0
int main(int argc, char *argv[])
{
	sub.init();

	rttest_read_args(argc, argv);

	if (rttest_set_sched_priority(90, SCHED_RR) != 0)
  {
    perror("Failed to set scheduling priority and policy of thread");
  }

	if (rttest_lock_memory() != 0)
  {
    perror("Failed to lock memory");
  }

	rttest_prefault_stack();

	rttest_spin(sub_callback, NULL);

	rttest_write_results();
	rttest_finish();

	sub.teardown();
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
  sub = new ExampleSubscriber();
	sub->init();

	rttest_read_args(argc, argv);
	if (rttest_set_sched_priority(90, SCHED_RR) != 0)
  {
    perror("Failed to set scheduling priority and policy of thread");
  }

  size_t pool_size = 1024*1024*1024;
  size_t stack_size = sizeof(*sub) + 1024*1024;
	if (rttest_lock_memory() != 0)
  {
    perror("Failed to lock memory");
  }

	rttest_prefault_stack();

	rttest_spin(sub_callback, NULL);

	rttest_write_results();
	rttest_finish();

  std::cout << "Subscriber received " << sub->msgs_count << " messages." << std::endl;
	sub->teardown();
  delete sub;
}
Exemplo n.º 3
0
void *publisher_thread(void *unused)
{
	rttest_spin(pub_callback, NULL);

	rttest_write_results_file("rttest_publisher_results");
  if (pub != NULL)
    pub->teardown();
	rttest_finish();
}
Exemplo n.º 4
0
  /// Wrap executor::spin into rttest_spin.
  // Do all the work available to the executor for as many iterations specified by rttest.
  void spin()
  {
    // This call will block until rttest is finished, calling loop_callback at periodic intervals
    // specified on the command line.
    rttest_spin(RttExecutor::loop_callback, static_cast<void *>(this));

    // Clean up state and write results after rttest has finished spinning.
    running = false;
    rttest_write_results();
    if (rttest_running()) {
      rttest_finish();
    }
    rttest_ready = rttest_running();
  }
Exemplo n.º 5
0
void *subscriber_thread(void *unused)
{
	rttest_init_new_thread();
	if (rttest_set_sched_priority(98, SCHED_RR) != 0)
  {
    perror("Failed to set scheduling priorty and policy of thread");
  }

	rttest_spin(sub_callback, NULL);
 
	rttest_write_results_file("rttest_subscriber_results");
  std::cout << "Subscriber received " << sub->msgs_count << " messages." << std::endl;
  /*if (sub != NULL)
    sub->teardown();*/
	rttest_finish();
}
Exemplo n.º 6
0
  /// Core component of the executor. Do a little bit of work and update extra state.
  // \param[in] Anonymous argument, will be casted as a pointer to an RttExecutor.
  static void * loop_callback(void * arg)
  {
    // Cast the argument so that we can access the executor's state.
    RttExecutor * executor = static_cast<RttExecutor *>(arg);
    // If the input pointer was NULL or invalid, or if rclcpp has stopped, signal rttest to stop.
    if (!executor || !rclcpp::utilities::ok()) {
      rttest_finish();
      return 0;
    }
    // Single-threaded spin_some: do as much work as we have available.
    executor->spin_some();

    // Retrieve rttest statistics accumulated so far and store them in the executor.
    rttest_get_statistics(&executor->results);
    rttest_get_sample_at(executor->results.iteration, &executor->last_sample);
    // In case this boolean wasn't set, notify that we've recently run the callback.
    executor->running = true;
    return 0;
  }
Exemplo n.º 7
0
int main(int argc, char ** argv)
{
  rttest_set_sched_priority(98, SCHED_RR);

  if (rttest_read_args(argc, argv) != 0) {
    perror("Couldn't read arguments for rttest");
    return -1;
  }
  if (rttest_lock_memory() != 0) {
    perror("Couldn't lock memory");
    return -1;
  }
  rttest_lock_and_prefault_dynamic();

  rttest_spin(my_loop_callback, NULL);

  rttest_write_results();
  rttest_finish();

  return 0;
}