/**********************************************************************************************************************
	CPlatformThreadImpl::Is_Running -- checks if the thread is currently running; answer may be erroneous by the time it's
		checked

		Returns: if the thread is running or not

**********************************************************************************************************************/
bool CPlatformThreadImpl::Is_Running( void ) const
{
	if ( !Is_Valid() )
	{
		return false;
	}

	DWORD exit_code = 0;
	::GetExitCodeThread( ThreadHandle, &exit_code );
			
	return ( exit_code == STILL_ACTIVE );
}
示例#2
0
void Obj_Data :: Extract( )
{
  obj_array*    array;
  int               i;

  if( !Is_Valid( ) ) {
    roach( "Extracting invalid object." );
    roach( "-- Valid = %d", valid );
    roach( "--   Obj = %s", this );
    return;
    }

  if( this->array != NULL ) 
    From( number );

  extract( contents );

  if( boot_stage == 2 )
    pIndexData->count -= number;

  clear_queue( this );
  stop_events( this );

  if( save != NULL ) {
    array = &save->save_list;
    for( i = 0; ; i++ ) {
      if( i >= array->size ) 
        panic( "Extract: Object not found in save array." );
      if( this == array->list[i] ) {
        array->list[i] = NULL;
        save = NULL;
        break;
        }
      }
    }

  delete_list( affected );
  free_string( source, MEM_OBJECT );

  if( singular != pIndexData->singular )
    free_string( singular, MEM_OBJECT );
  if( plural != pIndexData->plural )
    free_string( plural,   MEM_OBJECT );
  if( after != pIndexData->after )
    free_string( after,    MEM_OBJECT );
  if( before != pIndexData->before )
    free_string( before,   MEM_OBJECT );

  timer      = -2;
  valid      = -1;

  extracted += this;
}
/**********************************************************************************************************************
	CPlatformThreadImpl::Shutdown_Thread -- cleans up a Windows thread

**********************************************************************************************************************/
void CPlatformThreadImpl::Shutdown_Thread( void )
{
	if ( !Is_Valid() )
	{
		return;
	}

	DWORD exit_code = 0;
	::GetExitCodeThread( ThreadHandle, &exit_code );
			
	if ( exit_code == STILL_ACTIVE )
	{
		::TerminateThread( ThreadHandle, 1 );
	}

	::CloseHandle( ThreadHandle );
	ThreadHandle = nullptr;
}