c5aad72866b691fff524ad6d243bb7c26dc64577
[fleet.git] / src / edu / berkeley / fleet / api / FleetProcess.java
1 package edu.berkeley.fleet.api;
2 import java.io.*;
3 import java.util.*;
4
5 /** represents a <i>running</i> "slave" fleet with a debug connection */
6 public abstract class FleetProcess {
7
8     private boolean terminated = false;
9
10     /** dumps an instruction into the fetch unit */
11     public abstract void invokeInstruction(Instruction i);
12
13     /** reads a word back from the debug port */
14     public abstract long readWord();
15
16     /** subclasses may be assured that this will be called exactly once */
17     protected abstract void _terminate();
18
19     public synchronized void terminate() {
20         if (terminated) return;
21         terminated = true;
22         _terminate();
23     }
24
25     public boolean isTerminated() {
26         return terminated;
27     }
28
29     public synchronized void finalize() {
30         if (!terminated)
31             terminate();
32     }
33
34 }