add close() method
This commit is contained in:
parent
aa2cbaa89b
commit
c9ef9f4bb6
|
@ -36,7 +36,7 @@ public class Humidor {
|
||||||
private Object LOCK = new Object();
|
private Object LOCK = new Object();
|
||||||
private InvocationHandler _handler;
|
private InvocationHandler _handler;
|
||||||
private SigarProxy _sigar;
|
private SigarProxy _sigar;
|
||||||
private Sigar _impl;
|
private Sigar _impl, _inst;
|
||||||
|
|
||||||
private Humidor() {}
|
private Humidor() {}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class Humidor {
|
||||||
synchronized(LOCK) {
|
synchronized(LOCK) {
|
||||||
if (_sigar == null) {
|
if (_sigar == null) {
|
||||||
if (_impl == null) {
|
if (_impl == null) {
|
||||||
_impl = new Sigar();
|
_inst = _impl = new Sigar();
|
||||||
}
|
}
|
||||||
_handler = new MyHandler(_impl);
|
_handler = new MyHandler(_impl);
|
||||||
_sigar = (SigarProxy)
|
_sigar = (SigarProxy)
|
||||||
|
@ -84,4 +84,13 @@ public class Humidor {
|
||||||
public static Humidor getInstance() {
|
public static Humidor getInstance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//close the Sigar instance if getSigar() created it
|
||||||
|
public void close() {
|
||||||
|
if (_inst != null) {
|
||||||
|
_inst.close();
|
||||||
|
_impl = _inst = null;
|
||||||
|
}
|
||||||
|
_sigar = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue