Permalink
Browse files

Rethrow/retrigger interrupted status where appropriate

  • Loading branch information...
SquidDev committed May 10, 2017
1 parent 85c556d commit 5f323a85a7338717b99f080636b5305984a7f7ab
Showing with 22 additions and 14 deletions.
  1. +22 −14 src/main/java/dan200/computercraft/core/computer/ComputerThread.java
@@ -93,6 +93,13 @@ public static void stop()
}
}
}
synchronized( s_taskLock )
{
s_computerTaskQueues.clear();
s_computerTasksActive.clear();
s_computerTasksActiveSet.clear();
}
}
/**
@@ -157,10 +164,11 @@ public void run()
}
catch( InterruptedException ignored )
{
Thread.currentThread().interrupt();
}
}
private void execute( BlockingQueue<ITask> queue )
private void execute( BlockingQueue<ITask> queue ) throws InterruptedException
{
ITask task = queue.remove();
@@ -207,20 +215,19 @@ private void execute( BlockingQueue<ITask> queue )
}
}
}
catch( InterruptedException ignored )
{
}
// Re-add it back onto the queue or remove it
synchronized( s_taskLock )
finally
{
if( queue.isEmpty() )
{
s_computerTasksActiveSet.remove( queue );
}
else
// Re-add it back onto the queue or remove it
synchronized( s_taskLock )
{
s_computerTasksActive.add( queue );
if( queue.isEmpty() )
{
s_computerTasksActiveSet.remove( queue );
}
else
{
s_computerTasksActive.add( queue );
}
}
}
}
@@ -248,7 +255,7 @@ public void run()
{
task.execute();
}
catch( Throwable e )
catch( RuntimeException e )
{
ComputerCraft.log.error( "Error running task.", e );
}
@@ -259,6 +266,7 @@ public void run()
catch( InterruptedException e )
{
ComputerCraft.log.error( "Error running task.", e );
Thread.currentThread().interrupt();
}
}

0 comments on commit 5f323a8

Please sign in to comment.