TEST(queue, proverka_na_ravenstvo) { HQueue<int> *a = new HQueue<int> (2); a->push(5); HQueue<int> *b = new HQueue<int> (2); b->push(5); int c = a->operator==(*b); EXPECT_EQ(c,1); }
/** * Processos serão finalizados quando for invocada a chamada static void Process::exit(int status = 0), que precisa ser * implementada. A implementação dessa chamada deve desalocar a memória do processo invocando * void MemoryManager::deallocateMemory(Partition* partition), excluir todas as threads desse processo, excluir o processo (destruir * o objeto Process), invocar o escalonador para escolher outra thread, invocando Thread* Scheduler::choose() e então * o despachador para iniciar a execução da thread escolhida pelo escalonador, invocando * void Dispatcher::dispatch(Thread* previous, Thread* next). **/ void Process::exit(int status) { /*static*/ Debug::cout(Debug::Level::trace, "Process::exit(" + std::to_string(status) + ")"); if (Thread::running() != nullptr) { Process* proc = Thread::running()->getProcess(); System::memoryManager()->deallocateMemory(proc->_memInfo._partition); Process::getProcessesList()->remove(proc); // Segmentation fault is a bitch... HQueue<Thread*>* threads = new HQueue<Thread*>(); // criar lista e adicionar elas na lista depois excluir for (std::list<Thread*>::iterator it = Thread::getThreadsList()->begin(); it != Thread::getThreadsList()->end(); it++) { if ((*it)->getProcess() == proc) threads->push((*it)); } while (!threads->empty()) { Thread *t = threads->pop(); if (t->_state == Thread::State::READY) System::scheduler()->remove(t); delete t; } delete threads; delete proc; } Thread::chooseAndDispatch(); }
TEST(queue, proverka_popa) { HQueue<int> *a = new HQueue<int> (2); a->push(5); a->pop(); EXPECT_EQ(a->isEmpty(), 1); }
TEST(queue, proverka_topa) { HQueue<int> *a = new HQueue<int> (2); a->push(5); EXPECT_EQ(a->top(), 5); }