Commit c936f598 authored by Antônio Augusto Fröhlich's avatar Antônio Augusto Fröhlich
Browse files

Solving exercise about system object destruction

parent 7a2f9b44
......@@ -52,11 +52,22 @@ Thread::~Thread()
<< ",context={b=" << _context
<< "," << *_context << "})\n";
if(_state != FINISHING)
_thread_count--;
_ready.remove(this);
_suspended.remove(this);
switch(_state) {
case RUNNING: // Self deleted itself!
exit(-1);
break;
case READY:
_ready.remove(this);
break;
case SUSPENDED:
_suspended.remove(this);
break;
case WAITING:
_waiting->remove(this);
break;
case FINISHING: // Already called exit()
break;
}
unlock();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment