Ejemplo n.º 1
0
Archivo: set.c Proyecto: bjhua/dragon
void Set_insert (T set, Poly_t x)
{
  if (Set_exists (set, x))
    return;

  List_insertLast (set->list, x);
  return;
}
Ejemplo n.º 2
0
static List_t transBlocks (List_t blocks)
{
  List_t tmp, result = List_new ();
  
  Assert_ASSERT(blocks);
  
  tmp = List_getFirst (blocks);
  while (tmp){
    Ssa_Block_t b = (Ssa_Block_t)tmp->data;

    if (Property_get (visited, b))
      List_insertLast (result, b);
    tmp = tmp->next;
  }
  return result;
}
Ejemplo n.º 3
0
static void addRunningNode(ListNode* node) {
    static bool adding = false;
    
    // validate //
    if(node == NULL) return;
    Command* cmd = (Command*) node->data;
    if(cmd == NULL) { freeNode(node); return; }
    
    if(adding) {
        Info("Cannot start command during cancel(). Ignoring: %s", Command_getName(cmd));
        freeNode(node);
        return;
    }
    
    // make sure command is not already running //
    ListNode* xnode = runningList.firstNode;
    while(xnode != NULL) {
        if((Command*)xnode->data == cmd) {
            freeNode(node);
            return;
        }
        xnode = xnode->next;
    }
    
    // check that required Subsystems are available //
    Command* current;
    xnode = cmd->requiresList.firstNode;
    while(xnode != NULL) {
        current = ((Subsystem*) xnode->data)->currentCommand;
        if(current && !current->interruptible) {
            freeNode(node);
            return;
        }
        xnode = xnode->next;
    }
    
    // claim required Subsystems //
    adding = true;
    xnode = cmd->requiresList.firstNode;
    while(xnode != NULL) {
        Subsystem* sys = (Subsystem*) xnode->data;
        current = sys->currentCommand;
        if(current) {
            Command_cancel(current);
            // find the node with the command and remove it //
            ListNode* xnode2 = runningList.firstNode;
            while(xnode2 != NULL) {
                if((Command*)xnode2->data == current) {
                    removeRunningNode(xnode2);
                    break;
                }
                xnode2 = xnode2->next;
            }
        }
        sys->currentCommand = cmd;
        xnode = xnode->next;
    }
    adding = false;
    
    // add to command list //
    List_insertLast(&runningList, node);
    Command_startRunning(cmd);
}
Ejemplo n.º 4
0
static void freeNode(ListNode* node) {
    List_insertLast(&nodeCache, node);
}
Ejemplo n.º 5
0
void Scheduler_addButtonScheduler(ButtonScheduler* sched) {
    if(sched == NULL) return;
    List_insertLast(&buttonList, getNode(sched));
}
Ejemplo n.º 6
0
void Scheduler_add(Command* cmd) {
    if(cmd == NULL) return;
    List_insertLast(&queuedList, getNode(cmd));
}