Esempio n. 1
0
bool
MSVehicleControl::addVehicle(const std::string& id, SUMOVehicle* v) {
    VehicleDictType::iterator it = myVehicleDict.find(id);
    if (it == myVehicleDict.end()) {
        // id not in myVehicleDict.
        myVehicleDict[id] = v;
        const SUMOVehicleParameter& pars = v->getParameter();
        if (pars.departProcedure == DEPART_TRIGGERED || pars.departProcedure == DEPART_CONTAINER_TRIGGERED) {
            const MSEdge* const firstEdge = v->getRoute().getEdges()[0];
            if (!MSGlobals::gUseMesoSim) {
                // position will be checked against person position later
                static_cast<MSVehicle*>(v)->setTentativeLaneAndPosition(firstEdge->getLanes()[0], v->getParameter().departPos);
            }
            addWaiting(v->getRoute().getEdges().front(), v);
            registerOneWaiting(pars.departProcedure == DEPART_TRIGGERED);
        }
        if (pars.line != "" && pars.repetitionNumber < 0) {
            myPTVehicles.push_back(v);
        }
        return true;
    }
    return false;
}
Esempio n. 2
0
int main(){
  int fd, connfd;
  struct sockaddr_in cliaddr;
  socklen_t cliaddrlen = sizeof(cliaddr);
  
  /* Attempt to connect to socket */
  if((fd = connsock(8080)) == -1){
    perror("Connection to socket failed\n");
    return -1;
  }
  
  /*Create thread pool with 64 threads */
  ThreadPool * tp = init(64);
  if (tp == NULL){
#ifdef SERVER_DEBUG
    perror("Could not create ThreadPool");
#endif
    return -1;
  }
  
  for(;;){
    /* Try to accept a connection */
    if((connfd = accept(fd, (struct sockaddr *) &cliaddr, &cliaddrlen)) == -1){
      perror("Could not accept a connection");
      close(fd);
      return -1;
    }
    /* Add connection to stack inside Thread Pool for processing */
    if (addWaiting(tp,connfd)<0){
      perror("Could not add connection to stack");
    }
#ifdef SERVER_DEBUG
    printf("MAIN: New client added to work queue\n\n");
#endif
  }
  return 1;
}
Esempio n. 3
0
void sesc_wait(void)
{
  addWaiting(pthread_self());
}
Esempio n. 4
0
int sesc_suspend(int pid)
{
  addWaiting(pid);

  return 1;
}