Beispiel #1
0
 explicit event_loop(thread_factory tf)
     : factory(tf)
     , newthread(make_new_thread(tf))
     , count(0)
 {
     auto remaining = std::max(std::thread::hardware_concurrency(), unsigned(4));
     while (remaining--) {
         loops.push_back(newthread.create_worker());
     }
 }
Beispiel #2
0
 event_loop()
     : factory([](std::function<void()> start){
         return std::thread(std::move(start));
     })
     , newthread(make_new_thread())
     , count(0)
 {
     auto remaining = std::max(std::thread::hardware_concurrency(), unsigned(4));
     while (remaining--) {
         loops.push_back(newthread.create_worker());
     }
 }
Beispiel #3
0
int main () {
  pthread_t thread[2]; // thread ID
  Thread_Arg thread_arg;
  Command_Info info;
  char tmp[11]="M005500000\0";
  int i = 0;
  int ret =0;
  int cfin = 1;
  char c;

  printf("--- main ---\n");
  if(wiringPiSetupGpio() == -1){
    printf("---------wiringPiSetupGpio missing----------\r\n");
    return;
  }

  // thread arg init
  Thread_Arg_Init(&thread_arg);

  for ( i = 0; i < THREAD; i++ ) {
    make_new_thread(i, &thread[i], &thread_arg);
  }

  // waite thread end
  for(i = 0; i < THREAD; i++) {
    pthread_join(thread[i], NULL);
  }
  /*
  printf("=== Result ===\n");
  printf("recive data\n");
  printf("recive command\n");
  printf("large_type    : %c\n", thread_arg.command.large_type);
  printf("left_command  : %c\n", thread_arg.command.left_command);
  printf("right_command : %c\n", thread_arg.command.right_command);
  printf("OP3           : %c\n", thread_arg.command.OP3);
  printf("OP4           : %c\n", thread_arg.command.OP4);
  */
  sleep(1); /* モータ終了待ち */
  printf("### Main END ###\n");
  /* scanf("%c", &c); */

  return 0;
}