Bug fixes for thread unsafe simple timer and bad Ns treatment in AlignmentUtils

-- SimpleTimer is now threadsafe using synchronized method keywords
-- Bug fix for alignmentToByteArray() where the N case was refPos++ not the now correct refPos += elementLength
This commit is contained in:
Mark DePristo 2011-10-13 15:53:12 -04:00
parent 794f275871
commit 7cab6f6bb0
2 changed files with 5 additions and 6 deletions

View File

@ -58,7 +58,7 @@ public class SimpleTimer {
*/
@Requires("running == false")
@Ensures({"result != null", "elapsed == 0l"})
public SimpleTimer start() {
public synchronized SimpleTimer start() {
elapsed = 0l;
restart();
return this;
@ -73,7 +73,7 @@ public class SimpleTimer {
*/
@Requires("running == false")
@Ensures("result != null")
public SimpleTimer restart() {
public synchronized SimpleTimer restart() {
running = true;
startTime = currentTime();
return this;
@ -101,7 +101,7 @@ public class SimpleTimer {
*/
@Requires("running == true")
@Ensures({"result != null", "elapsed >= old(elapsed)", "running == false"})
public SimpleTimer stop() {
public synchronized SimpleTimer stop() {
running = false;
elapsed += currentTime() - startTime;
return this;
@ -116,11 +116,10 @@ public class SimpleTimer {
@Ensures({
"result >= (elapsed/1000.0)",
"result >= 0"})
public double getElapsedTime() {
public synchronized double getElapsedTime() {
return (running ? (currentTime() - startTime + elapsed) : elapsed) / 1000.0;
}
public void printElapsedTime(PrintStream out) {
out.printf("SimpleTimer %s: %.2f%n", name, getElapsedTime());
}

View File

@ -353,7 +353,7 @@ public class AlignmentUtils {
break;
case D:
case N:
refPos++;
refPos += elementLength;
break;
case M:
for ( int jjj = 0; jjj < elementLength; jjj++ ) {