Exemplo n.º 1
0
void
DaemonInstance::StateThreads (Layer3 * l3, Logs * t, ClientConnection * c,
              pth_event_t stop)
{
  uchar buf[3];
  EIBSETTYPE (buf, EIB_STATE_REQ_THREADS);
  buf[2] = 0;

  c->sendmessage (sizeof(buf), buf, stop);

  pth_ctrl(PTH_CTRL_DUMPSTATE, stdout);
  for ( Thread::pthset::iterator i= Thread::get_running_threads().begin(); i!= Thread::get_running_threads().end(); ++i)
    {
      unsigned char *n;
      static pth_time_t t;
      static pth_attr_t tr;
      int dispatches;
      tr=pth_attr_of(*i);
      pth_attr_get(tr,PTH_ATTR_NAME,&n);
      pth_attr_get(tr,PTH_ATTR_TIME_RAN,&t);
      pth_attr_get(tr,PTH_ATTR_DISPATCHES,&dispatches);
      printf("0x%lx %32s:%6d:\t", (unsigned long) *i, n, (int) dispatches);
      printf("%ld.%ld\n", (unsigned long) t.tv_sec,
                          (unsigned long) t.tv_usec/1000);
    }
}
Exemplo n.º 2
0
bool Thread::isFinished ()
{
    if (tid ==0)
        return true;
    pth_attr_t a = pth_attr_of (tid);
    int state;
    pth_attr_get (a, PTH_ATTR_STATE, &state);
    pth_attr_destroy (a);
    return (state == PTH_STATE_DEAD);
}
Exemplo n.º 3
0
void
Thread::Start ()
{
  if (tid)
    {
      pth_attr_t a = pth_attr_of (tid);
      int state;
      pth_attr_get (a, PTH_ATTR_STATE, &state);
      pth_attr_destroy (a);
      if (state != PTH_STATE_DEAD)
	return;
      Stop ();
    }
  pth_attr_t attr = pth_attr_new ();
  pth_attr_set (attr, PTH_ATTR_PRIO, prio);
  tid = pth_spawn (attr, &ThreadWrapper, this);
  pth_attr_destroy (attr);
}
Exemplo n.º 4
0
void
Thread::Start (bool detach)
{
    if (joinable && tid)
    {
        pth_attr_t a = pth_attr_of (tid);
        int state;
        pth_attr_get (a, PTH_ATTR_STATE, &state);
        pth_attr_destroy (a);
        if (state != PTH_STATE_DEAD)
            return;
        Stop ();
    }
    pth_sem_init (&should_stop);
    pth_attr_t attr = pth_attr_new ();
    pth_attr_set (attr, PTH_ATTR_PRIO, prio);
    joinable = !detach;
    if (detach)
        pth_attr_set (attr, PTH_ATTR_JOINABLE, FALSE);
    tid = pth_spawn (attr, &ThreadWrapper, this);
    pth_attr_destroy (attr);
}