~ubuntu-branches/ubuntu/raring/ginkgocadx/raring-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/main/controllers/controladorcomandos.cpp

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2011-09-09 08:39:26 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: package-import@ubuntu.com-20110909083926-iktecd132cnku5cd
Tags: 2.5.4.0~rc-1
New upstream version (patches were applied)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *  
3
 
 *  $Id: controladorcomandos.cpp 3849 2011-05-16 13:26:20Z carlos $
 
3
 *  $Id: controladorcomandos.cpp 4078 2011-08-16 10:19:52Z tovar $
4
4
 *  Ginkgo CADx Project
5
5
 *
6
6
 *  Copyright 2008-10 MetaEmotion S.L. All rights reserved.
563
563
        GTRACE("<< ControladorComandos::AbortarComandosDeOwner(owner) : CS");
564
564
}
565
565
 
 
566
void GNC::GCS::ControladorComandos::WaitToOwnerCommands(void* owner)
 
567
{
 
568
        GNC::GCS::WaitQueue wqueue;
 
569
 
 
570
        {
 
571
                GNC::GCS::ILocker locker(this, GLOC());
 
572
                GTRACE(">> ControladorComandos::AbortarComandosDeOwner(owner) : CS");
 
573
                // Recorremos la lista de threads_ids de la vista
 
574
                MapaOwners::iterator it1 = m_MapaOwners.find(owner);
 
575
                MapaComandos::iterator itcl;
 
576
                if (it1 != m_MapaOwners.end()) {
 
577
                        for (ListaHilos::iterator it2 = (*it1).second.begin(); it2 != (*it1).second.end(); it2++) {
 
578
                                long threadId = (*it2);
 
579
                                // Buscamos el id en la lista de comandos lanzados
 
580
                                itcl = m_ComandosLanzados.find(threadId);
 
581
                                if (itcl != m_ComandosLanzados.end()) { // El comando esta lanzado
 
582
                                        LanzadorComandos* pLanzador = (*itcl).second;
 
583
                                        if (pLanzador != NULL) { //
 
584
 
 
585
                                                wqueue.RegistrarEspera(pLanzador, GLOC());
 
586
                                                pLanzador->Terminar();
 
587
 
 
588
                                                std::cerr << "Registrando espera para tarea: threadId = " << (unsigned long) threadId << " ptr = " << pLanzador << std::endl;
 
589
                                        } else {
 
590
                                                std::cerr << "Detectada inconsistencia en el controlador de comandos: Comando lanzado desreferenciado. Flujo de comando perdido." << std::endl;
 
591
                                        }
 
592
                                }
 
593
                        }
 
594
                }
 
595
                GTRACE("<< ControladorComandos::WaitToOwnerCommands(owner) : CS");
 
596
        }
 
597
 
 
598
        GTRACE("GNC::GCS::ControladorComandos::WaitToOwnerCommands( " << owner << ") : Esperando " << wqueue.Size(GLOC()) << " tareas");
 
599
        while (wqueue.NotEmpty(GLOC())) {
 
600
                if (!wqueue.Wait(500, GLOC())) {
 
601
                }
 
602
        }
 
603
        GTRACE("GNC::GCS::ControladorComandos::WaitToOwnerCommands( " << owner << ") : Espera terminada");
 
604
}
 
605
 
566
606
void GNC::GCS::ControladorComandos::OnComandoLanzado(long threadId)
567
607
{
568
608