autohit.vm
Class VMObject

java.lang.Object
  extended byautohit.vm.VMObject

public class VMObject
extends java.lang.Object

This is a lock-able, set-able object. Field item holds the actual data.

Version:
1.0 Version History EPG - Initial - 8may03
Author:
Erich P. Gatejen

Constructor Summary
VMObject()
          Default Constructor.
VMObject(java.lang.Object o)
          Creator Constructor.
 
Method Summary
 void free()
          Cancel all locks
 java.lang.Object get()
          Get the object
 void lock()
          The calling thread will try to lock it.
 void set(java.lang.Object o)
          Set the object
 boolean test()
          Test if I can access it
 void unlock()
          Knock the spinlock down one.
 void waitingLock()
          Get the object.
 java.lang.Object waitingRead()
          Get the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VMObject

public VMObject()
Default Constructor.


VMObject

public VMObject(java.lang.Object o)
Creator Constructor.

Parameters:
o - the object
Method Detail

lock

public void lock()
          throws VMException
The calling thread will try to lock it. If successful, it will spinlock it

Throws:
VMException - if it is already locked.

test

public boolean test()
Test if I can access it

Returns:
true if I can

unlock

public void unlock()
            throws VMException
Knock the spinlock down one. If it hits zero, the lock is removed.

Throws:
VMException - if it locked by something else.

free

public void free()
          throws VMException
Cancel all locks

Throws:
VMException - if it locked by something else.

set

public void set(java.lang.Object o)
         throws VMException
Set the object

Throws:
VMException - if it locked by something else.

get

public java.lang.Object get()
                     throws VMException
Get the object

Returns:
the object
Throws:
VMException - if it locked by something else.

waitingRead

public java.lang.Object waitingRead()
Get the object. Wait for it to be free if locked. This is pretty dangerous source of deadlock. Be careful!

Returns:
the object
Throws:
VMException - if it locked by something else.

waitingLock

public void waitingLock()
Get the object. Wait for it to be free if locked. This is pretty dangerous source of deadlock. Be careful!

Returns:
the object
Throws:
VMException - if it locked by something else.


Test.