[vlma-devel] commit: Simplification. (Adrien Grand )
git version control
git at videolan.org
Fri Feb 27 04:26:08 CET 2009
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Fri Feb 27 03:21:49 2009 +0100| [cffbbd16d4f57b77e72ebbbe004d80b3f90f97cb] | committer: Adrien Grand
Simplification.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=cffbbd16d4f57b77e72ebbbe004d80b3f90f97cb
---
.../org/videolan/vlma/monitor/OrderMonitor.java | 25 ++++++++-----------
.../org/videolan/vlma/monitor/ServerMonitor.java | 9 +++----
.../videolan/vlma/monitor/ServerStateMonitor.java | 9 +++----
3 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
index dd6ce76..ce6bdd7 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
@@ -20,9 +20,6 @@
package org.videolan.vlma.monitor;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-
import org.apache.commons.configuration.Configuration;
import org.apache.log4j.Logger;
import org.videolan.vlma.model.Program;
@@ -42,32 +39,32 @@ public class OrderMonitor extends Monitor {
private Configuration configuration;
private OrderManager orderManager;
- private AtomicBoolean shouldRun;
+ private volatile boolean shouldRun;
private boolean orderGivingPending;
- private AtomicLong lastOrderGiving;
+ private volatile long lastOrderGiving;
private Thread orderMonitor;
private Runnable orderMonitorRunnable;
public OrderMonitor() {
orderMonitor = null;
orderGivingPending = false;
- shouldRun = new AtomicBoolean(false);
- lastOrderGiving = new AtomicLong(0L);
+ shouldRun = true;
+ lastOrderGiving = 0L;
registerMonitor(this);
orderMonitorRunnable = new Runnable() {
public void run() {
- while(shouldRun.get()) {
+ while(shouldRun) {
try {
Thread.sleep(configuration.getLong("vlma.monitor.order.check.interval") * 1000L);
} catch (InterruptedException e) {
continue;
}
long currentTime = System.currentTimeMillis();
- if(currentTime - lastOrderGiving.get() > configuration.getLong("vlma.monitor.order.give.interval") * 1000L) {
- lastOrderGiving.set(currentTime);
+ if(currentTime - lastOrderGiving > configuration.getLong("vlma.monitor.order.give.interval") * 1000L) {
+ lastOrderGiving = currentTime;
if(orderManager.updateOrders())
orderManager.giveOrders();
- lastOrderGiving.set(currentTime);
+ lastOrderGiving = currentTime;
} else {
orderManager.updateMedias();
}
@@ -88,7 +85,7 @@ public class OrderMonitor extends Monitor {
return;
}
logger.info("Starting order monitor");
- shouldRun.set(true);
+ shouldRun = true;
orderMonitor = new Thread(MonitorThreadGroup.getInstance(), orderMonitorRunnable);
orderMonitor.setName("Order Monitor");
orderMonitor.start();
@@ -96,7 +93,7 @@ public class OrderMonitor extends Monitor {
public synchronized void stop() {
logger.info("Stopping order monitor");
- shouldRun.set(false);
+ shouldRun = false;
orderMonitor.interrupt();
}
@@ -139,7 +136,7 @@ public class OrderMonitor extends Monitor {
orderManager.updateOrders();
orderManager.giveOrders();
orderGivingPending = false;
- lastOrderGiving.set(System.currentTimeMillis());
+ lastOrderGiving = System.currentTimeMillis();
}
};
orderGiver.setName("Order Giver");
diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java
index 2e35ff5..0381580 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java
@@ -22,7 +22,6 @@ package org.videolan.vlma.monitor;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.log4j.Logger;
import org.jrobin.core.Util;
@@ -55,7 +54,7 @@ public class ServerMonitor extends Monitor {
private Thread serverMonitor;
- private AtomicBoolean shouldRun = new AtomicBoolean(false);
+ private volatile boolean shouldRun;
public synchronized boolean isRunning() {
return (serverMonitor != null)
@@ -89,8 +88,8 @@ public class ServerMonitor extends Monitor {
*/
Runnable serverMonitorDaemon = new Runnable() {
public void run() {
- shouldRun.set(true);
- while (shouldRun.get()) {
+ shouldRun = true;
+ while (shouldRun) {
try {
// Wait before looping
Thread.sleep(1000 * (TIME_INTERVAL - (Util.getTime() % TIME_INTERVAL)));
@@ -115,7 +114,7 @@ public class ServerMonitor extends Monitor {
public synchronized void stop() {
logger.info("Stopping " + this.getClass().getSimpleName());
- shouldRun.set(false);
+ shouldRun = false;
serverMonitor.interrupt();
}
diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerStateMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerStateMonitor.java
index e0f0cc0..45c24f3 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerStateMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerStateMonitor.java
@@ -23,7 +23,6 @@ package org.videolan.vlma.monitor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.configuration.Configuration;
import org.apache.log4j.Logger;
@@ -49,14 +48,14 @@ public class ServerStateMonitor extends Monitor {
private Thread serverStateMonitor;
private Runnable serverStateMonitorRunnable;
- private AtomicBoolean shouldRun = new AtomicBoolean(true);
+ private volatile boolean shouldRun;
public ServerStateMonitor() {
serverStateMonitorRunnable = new Runnable() {
public void run() {
checkVLCs();
- shouldRun.set(true);
- while (shouldRun.get()) {
+ shouldRun = true;
+ while (shouldRun) {
try {
// Wait before looping
Thread.sleep(1000L * configuration.getLong("vlma.monitor.server.interval"));
@@ -157,7 +156,7 @@ public class ServerStateMonitor extends Monitor {
public synchronized void stop() {
logger.info("Stopping " + this.getClass().getSimpleName());
- shouldRun.set(false);
+ shouldRun = false;
serverStateMonitor.interrupt();
}
More information about the vlma-devel
mailing list