edu.ntnu.item.jt.system
Class CallbackProc

java.lang.Object
  extended by edu.ntnu.item.jt.system.CallbackProc
All Implemented Interfaces:
com.sun.jna.Callback

public class CallbackProc
extends java.lang.Object
implements com.sun.jna.Callback

A simple generic callback procedure which accepts a callback, responds on queries of whether the callback has been received and releases the job from the Vix API upon completion. Callbacks are used when executing operations in the Vix API in a non-blocking manner. The Vix API (via JNA) will call the provided callback when the given operation is finished.

Author:
Jøran Vagnby Lillesand
See Also:
Callback

Field Summary
 
Fields inherited from interface com.sun.jna.Callback
METHOD_NAME
 
Constructor Summary
CallbackProc(GuestOS guestOS)
          Creates a new CallbackProc instance.
 
Method Summary
 void callback()
          Called by JNA/Vix when the operation is completed.
protected  void finalize()
          Unregister the job with the Vix API to free up any reserved resources.
 boolean isFinished()
          Check whether the callback has been received.
 void setJobHandle(int jobHandle)
          Sets the job handle associated with this job.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallbackProc

public CallbackProc(GuestOS guestOS)
Creates a new CallbackProc instance. Takes a reference to the guest OS on which the job is being executed. This is later used to free up the resources associated with the job.

Parameters:
guestOS -
Method Detail

setJobHandle

public void setJobHandle(int jobHandle)
Sets the job handle associated with this job. This should be done at some time before the object is finalized, at which point the job handle is used to free up the resources allocated to this job by the Vix API.

Parameters:
jobHandle - handle of the job that is being executed.

callback

public void callback()
Called by JNA/Vix when the operation is completed.


isFinished

public boolean isFinished()
Check whether the callback has been received.

Returns:
true if the operation has finished, false if not.

finalize

protected void finalize()
Unregister the job with the Vix API to free up any reserved resources.

Overrides:
finalize in class java.lang.Object