[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17963 - in gnunet-java: . src/org/gnunet/util/scheduler
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17963 - in gnunet-java: . src/org/gnunet/util/scheduler |
Date: |
Thu, 3 Nov 2011 15:07:03 +0100 |
Author: grothoff
Date: 2011-11-03 15:07:02 +0100 (Thu, 03 Nov 2011)
New Revision: 17963
Removed:
gnunet-java/src/org/gnunet/util/scheduler/ScheduleSpec.java
gnunet-java/src/org/gnunet/util/scheduler/Task.java
Modified:
gnunet-java/ISSUES
gnunet-java/src/org/gnunet/util/scheduler/Scheduler.java
Log:
some ideas
Modified: gnunet-java/ISSUES
===================================================================
--- gnunet-java/ISSUES 2011-11-03 13:28:59 UTC (rev 17962)
+++ gnunet-java/ISSUES 2011-11-03 14:07:02 UTC (rev 17963)
@@ -1,17 +1,23 @@
* what about licensing of libraries in general?
+ => GPLv3+ or compatible (d.h. GPLv2+, LGPLv2+, BSD, Apache License 2.0+)
+ http://www.gnu.org/licenses/quick-guide-gplv3.html
+
* java has no native unix domain sockets (=>use JNI library, licensing issues?)
+
* package structure, inner classes vs. packages
-* naming conventions: stick with java standards?
-* ugly cross-reference to TransmitReadyNotify.java in
org.gnunet.util.client.Client
-* Client/Connection class hierarchy
-* how to handle disconnect/destroy (as java cannot directly dispose of objects)
-* why is configuration passed around so often?
-* wrt the scheduler: can you select on anything else than a Connection?
+
+* naming conventions: stick with java standards? YES.
+* ugly cross-reference to TransmitReadyNotify.java in
org.gnunet.util.client.Client => util/TransmitReadyNotify interface
+* Client/Connection class hierarchy => avoid deep hierarchies!
+* how to handle disconnect/destroy (as java cannot directly dispose of
objects) => finalizers
+* why is configuration passed around so often? Because we may have multiple!
+* wrt the scheduler: can you select on anything else than a Connection? pipes,
sockets (tcp/udp), files, timeout
+
Used Libraries:
- * https://github.com/magnuss/java-bloomfilter (LGPL)
+ * https://github.com/magnuss/java-bloomfilter (LGPL) => freeway!
* http://code.google.com/p/junixsocket/ (Apache License 2.0)
\ No newline at end of file
Deleted: gnunet-java/src/org/gnunet/util/scheduler/ScheduleSpec.java
===================================================================
--- gnunet-java/src/org/gnunet/util/scheduler/ScheduleSpec.java 2011-11-03
13:28:59 UTC (rev 17962)
+++ gnunet-java/src/org/gnunet/util/scheduler/ScheduleSpec.java 2011-11-03
14:07:02 UTC (rev 17963)
@@ -1,34 +0,0 @@
-package org.gnunet.util.scheduler;
-
-import java.nio.channels.Channel;
-
-public class ScheduleSpec {
- /**
- * require the completion of another task before starting this one
- */
- public void setPrerequisiteTask(Task t) {
- throw new UnsupportedOperationException();
- }
-
- public void addWritable(Channel c) {
- throw new UnsupportedOperationException();
- }
-
- public void addReadable(Channel c) {
- throw new UnsupportedOperationException();
- }
-
- public void setDelay() {
- throw new UnsupportedOperationException();
- }
-
- public void setPriority(Task.Priority p) {
- throw new UnsupportedOperationException();
- }
-
- public void setLiveness(boolean liveness) {
- throw new UnsupportedOperationException();
- }
-
-
-}
Modified: gnunet-java/src/org/gnunet/util/scheduler/Scheduler.java
===================================================================
--- gnunet-java/src/org/gnunet/util/scheduler/Scheduler.java 2011-11-03
13:28:59 UTC (rev 17962)
+++ gnunet-java/src/org/gnunet/util/scheduler/Scheduler.java 2011-11-03
14:07:02 UTC (rev 17963)
@@ -1,16 +1,114 @@
+// FIXME: license
+
package org.gnunet.util.scheduler;
-import java.util.LinkedList;
+import org.gnunet.util.time.AbsoluteTime;
+import org.gnunet.util.time.RelativeTime;
-import javax.naming.OperationNotSupportedException;
+/**
+ *
+ * @author
+ */
+public class Scheduler {
-public class Scheduler {
+ public enum Priority {
+ KEEP, IDLE, BACKGROUND, DEFAULT, HIGH, UI, URGENT, SHUTDOWN
+ };
+
public enum Reason {
- // XXX: do these values need to be 2^n? are they used in a bit
mask?
+ // XXX: do these values need to be 2^n? are they used in a bit
mask? YES
STARTUP, SHUTDOWN, TIMEOUT, READ_READY, WRITE_READY, PREREQ_DONE
};
+
+
+ public interface Task {
+
+ public void run (Context ctx);
+
+ public static class Context
+ {
+ Reason reason;
+
+ // read-ready set
+ // write-ready set
+ };
+
+ }
+
+ /*
+ * Task subsumes gnunet-c's TaskContext and TaskIdentifier
+ */
+
+ public static abstract class TaskIdentifier {
+
+ private final Task task;
+
+ TaskIdentifier (Task t)
+ {
+ this.task = t;
+ }
+
+ /*
+ * // Unique Task Identifier, XXX do we/ need this? int id;
+ *
+ * int prereq_id;
+ *
+ * AbsoluteTime timeout;
+ *
+ * AbsoluteTime start_time;
+ *
+ * int read_fd, write_fd;
+ *
+ * int lifeness;
+ */
+
+ /*
+ * The actual code a task is supposed to execute
+ */
+ void run(Task.Context ctx)
+ {
+ task.run(ctx);
+ }
+
+ public abstract void cancel ();
+ }
+
+ static class TimeoutTask extends TaskIdentifier {
+
+ final AbsoluteTime timeout;
+
+ TimeoutTask (RelativeTime delay, Task t)
+ {
+ super (t);
+ timeout = delay.toAbsolute();
+ // timeout_heap.add (dti.timeout, this);
+ }
+ // private final AbsoluteTime timeout;
+
+ public void cancel () {
+ // timeout_heap.remove (this);
+ }
+
+ }
+
/**
+ * Run the task as soon as its prerequisites are satisfied.
+ */
+ public void add(Task task) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Run the task as soon as its prerequisites are satisfied.
+ */
+ public TaskIdentifier add_delayed(RelativeTime delay, Task task) {
+ return new TimeoutTask (delay, task);
+ }
+
+
+
+ /**
* Initialize and run scheduler. This function will return when all
tasks
* have completed. On systems with signals, receiving a SIGTERM (and
other
* similar signals) will cause "GNUNET_SCHEDULER_shutdown" to be run
after
@@ -26,77 +124,67 @@
public void run(Task task, ScheduleSpec spec) {
throw new UnsupportedOperationException();
}
-
+
/**
* run with default spec (=> as soon as possible)
*/
public void run(Task task) {
throw new UnsupportedOperationException();
}
-
-
+
/**
* Run the task as soon as its prerequisites are satisfied.
*/
public void schedule(Task task) {
throw new UnsupportedOperationException();
}
-
-
+
/**
* Run the task regardless of any prerequisites.
*/
public void setNext(Task task, Reason reason) {
throw new UnsupportedOperationException();
}
-
-
-
+
/**
- * Request the shutdown of a scheduler. Marks all currently
- * pending tasks as ready because of shutdown. This will
- * cause all tasks to run (as soon as possible, respecting
- * priorities and prerequisite tasks). Note that tasks
+ * Request the shutdown of a scheduler. Marks all currently pending
tasks as
+ * ready because of shutdown. This will cause all tasks to run (as soon
as
+ * possible, respecting priorities and prerequisite tasks). Note that
tasks
* scheduled AFTER this call may still be delayed arbitrarily.
*/
public void shutdown() {
throw new UnsupportedOperationException();
}
-
-
+
/**
- * Get information about the current load of this scheduler. Use this
+ * Get information about the current load of this scheduler. Use this
* function to determine if an elective task should be added or simply
- * dropped (if the decision should be made based on the number of
- * tasks ready to run).
- *
- * * @param p priority-level to query, use KEEP to query the level
- * of the current task, use COUNT to get the sum over
- * all priority levels
+ * dropped (if the decision should be made based on the number of tasks
+ * ready to run).
+ *
+ * * @param p priority-level to query, use KEEP to query the level of
the
+ * current task, use COUNT to get the sum over all priority levels
+ *
* @return number of tasks pending right now
*/
- public int getLoad (Task.Priority p) {
+ public int getLoad(Priority p) {
throw new UnsupportedOperationException();
}
-
-
+
/**
- * Obtain the reason code for why the current task was
- * started. Will return the same value as
- * the GNUNET_SCHEDULER_TaskContext's reason field.
- *
+ * Obtain the reason code for why the current task was started. Will
return
+ * the same value as the GNUNET_SCHEDULER_TaskContext's reason field.
+ *
* * @return reason(s) why the current task is run
*/
public Reason getReason() {
throw new UnsupportedOperationException();
}
-
/**
- * Cancel execution of the specified task.
- * The task must not yet have run.
+ * Cancel execution of the specified task. The task must not yet have
run.
*/
- public void cancel (Task task) {
+ public void cancel(Task task) {
throw new UnsupportedOperationException();
}
}
Deleted: gnunet-java/src/org/gnunet/util/scheduler/Task.java
===================================================================
--- gnunet-java/src/org/gnunet/util/scheduler/Task.java 2011-11-03 13:28:59 UTC
(rev 17962)
+++ gnunet-java/src/org/gnunet/util/scheduler/Task.java 2011-11-03 14:07:02 UTC
(rev 17963)
@@ -1,38 +0,0 @@
-package org.gnunet.util.scheduler;
-
-import org.gnunet.util.time.AbsoluteTime;
-
-
-/*
- * Task subsumes gnunet-c's TaskContext and TaskIdentifier
- */
-
-public abstract class Task {
-
- public enum Priority {
- KEEP, IDLE, BACKGROUND, DEFAULT, HIGH, UI, URGENT, SHUTDOWN
- };
-
- /*
- // Unique Task Identifier, XXX do we/ need this?
- int id;
-
- int prereq_id;
-
- AbsoluteTime timeout;
-
- AbsoluteTime start_time;
-
- int read_fd, write_fd;
-
- int lifeness;
- */
-
-
-
-
- /*
- * The actual code a task is supposed to execute
- */
- abstract void run();
-}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17963 - in gnunet-java: . src/org/gnunet/util/scheduler,
gnunet <=