[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17949 - in gnunet-java: . src/org/gnunet/util/network src/
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17949 - in gnunet-java: . src/org/gnunet/util/network src/org/gnunet/util/scheduler src/org/gnunet/util/time |
Date: |
Wed, 2 Nov 2011 20:31:21 +0100 |
Author: dold
Date: 2011-11-02 20:31:21 +0100 (Wed, 02 Nov 2011)
New Revision: 17949
Added:
gnunet-java/src/org/gnunet/util/scheduler/TaskInfo.java
Removed:
gnunet-java/src/org/gnunet/util/scheduler/Task.java
Modified:
gnunet-java/ISSUES
gnunet-java/src/org/gnunet/util/network/Client.java
gnunet-java/src/org/gnunet/util/network/Connection.java
gnunet-java/src/org/gnunet/util/scheduler/Scheduler.java
gnunet-java/src/org/gnunet/util/scheduler/TaskContext.java
gnunet-java/src/org/gnunet/util/time/RelativeTime.java
Log:
scheduler
Modified: gnunet-java/ISSUES
===================================================================
--- gnunet-java/ISSUES 2011-11-02 19:19:59 UTC (rev 17948)
+++ gnunet-java/ISSUES 2011-11-02 19:31:21 UTC (rev 17949)
@@ -11,4 +11,6 @@
Used Libraries:
* https://github.com/magnuss/java-bloomfilter (LGPL)
- * http://code.google.com/p/junixsocket/ (Apache License 2.0)
\ No newline at end of file
+ * http://code.google.com/p/junixsocket/ (Apache License 2.0)
+
+
\ No newline at end of file
Modified: gnunet-java/src/org/gnunet/util/network/Client.java
===================================================================
--- gnunet-java/src/org/gnunet/util/network/Client.java 2011-11-02 19:19:59 UTC
(rev 17948)
+++ gnunet-java/src/org/gnunet/util/network/Client.java 2011-11-02 19:31:21 UTC
(rev 17949)
@@ -1,7 +1,7 @@
package org.gnunet.util.network;
import org.gnunet.util.config.Configuration;
-import org.gnunet.util.scheduler.Task;
+import org.gnunet.util.scheduler.TaskInfo;
import org.gnunet.util.time.RelativeTime;
public class Client {
@@ -117,7 +117,7 @@
* or "TIMEOUT" (service not known to be running))
*/
- public static void serviceTest(String service_name, Configuration cfg,
RelativeTime timeout, Task t) {
+ public static void serviceTest(String service_name, Configuration cfg,
RelativeTime timeout, TaskInfo t) {
throw new UnsupportedOperationException();
}
}
Modified: gnunet-java/src/org/gnunet/util/network/Connection.java
===================================================================
--- gnunet-java/src/org/gnunet/util/network/Connection.java 2011-11-02
19:19:59 UTC (rev 17948)
+++ gnunet-java/src/org/gnunet/util/network/Connection.java 2011-11-02
19:31:21 UTC (rev 17949)
@@ -89,8 +89,6 @@
* NULL and size 0)?
* @param notify
* function to call when buffer space is available
- * @param notify_cls
- * closure for notify
* @return non-NULL if the notify callback was queued, NULL if we are
* already going to notify someone else (busy)
*/
Modified: gnunet-java/src/org/gnunet/util/scheduler/Scheduler.java
===================================================================
--- gnunet-java/src/org/gnunet/util/scheduler/Scheduler.java 2011-11-02
19:19:59 UTC (rev 17948)
+++ gnunet-java/src/org/gnunet/util/scheduler/Scheduler.java 2011-11-02
19:31:21 UTC (rev 17949)
@@ -5,43 +5,146 @@
import javax.naming.OperationNotSupportedException;
public class Scheduler {
- enum Reason {STARTUP, SHUTDOWN, TIMEOUT, READ_READY, WRITE_READY,
PREREQ_DONE};
- enum Priority {KEEP, IDLE, BACKGROUND, DEFAULT, HIGH, UI, URGENT,
SHUTDOWN, COUNT};
+ public enum Reason {
+ // XXX: do these values need to be 2^n? are they used in a bit
mask?
+ STARTUP, SHUTDOWN, TIMEOUT, READ_READY, WRITE_READY, PREREQ_DONE
+ };
+
+ public enum Priority {
+ KEEP, IDLE, BACKGROUND, DEFAULT, HIGH, UI, URGENT, SHUTDOWN
+ };
+
+ private LinkedList<Task> pending;
+ private LinkedList<Task> pending_timeout;
+
+ private LinkedList<Task> ready;
+
+ private Task pending_timeout_last;
+ private Task active_task;
+
+ private int last_id;
+
+ private int lowest_pending_id;
+
+ private int ready_count;
+
+ private long tasks_run;
+
+ /**
+ * 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
+ * the active task is complete. As a result, SIGTERM causes all active
tasks
+ * to be scheduled with reason "GNUNET_SCHEDULER_REASON_SHUTDOWN".
(However,
+ * tasks added afterwards will execute normally!). Note that any
particular
+ * signal will only shut down one scheduler; applications should always
only
+ * create a single scheduler.
+ *
+ * @param task
+ * task to run first (and immediately)
+ */
+
+ public void run(Task task) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addContinuation(TaskCallback t, Reason r) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addAfter(Task prereq, TaskCallback t) {
+
+ }
+
- LinkedList<Task> pending;
- LinkedList<Task> pending_timeout;
+ /**
+ * 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();
+ }
- LinkedList<Task> ready;
- Task pending_timeout_last;
- Task active_task;
- int last_id;
-
- int lowest_pending_id;
-
- int ready_count;
-
- long tasks_run;
-
-
- public void run(Task t) {
+ /**
+ * 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
+ * @return number of tasks pending right now
+ */
+ public int getLoad (Priority p) {
throw new UnsupportedOperationException();
}
- public void addContinuation(TaskCallback t, Reason r) {
+
+ /**
+ * 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();
}
+
- public void addAfter(Task prereq, TaskCallback t) {
+ /**
+ * Cancel the task with the specified identifier.
+ * The task must not yet have run.
+ *
+ * * @param task id of the task to cancel
+ * @return the closure of the callback of the cancelled task
+ */
+ // XXX: do we need to return the task?
+ public void cancel (TaskIdentifier task) {
}
- public void shutdown() {
- throw new UnsupportedOperationException();
+ /**
+ * Schedule a new task to be run with a specified priority.
+ *
+ * * @param prio how important is the new task?
+ * @param task main function of the task
+ * @param task_cls closure of task
+ * @return unique task identifier for the job
+ * only valid until "task" is started! (XXX: we don't need
this, do we?)
+ */
+ public void addWithPriority (Priority prio, Task task) {
+
}
+ /**
+ * Schedule a new task to be run as soon as possible. The task
+ * will be run with the priority of the calling task.
+ *
+ * * @param task main function of the task
+ * @param task_cls closure of task
+ * @return unique task identifier for the job
+ * only valid until "task" is started!
+ */
+ public void add_now (Task task, void *task_cls) {
+
+ }
+
+
+
+ /*
+ * set_select is not relevant in java (we use java's nio api for
sockets)
+ */
+
+
+
}
Deleted: gnunet-java/src/org/gnunet/util/scheduler/Task.java
===================================================================
--- gnunet-java/src/org/gnunet/util/scheduler/Task.java 2011-11-02 19:19:59 UTC
(rev 17948)
+++ gnunet-java/src/org/gnunet/util/scheduler/Task.java 2011-11-02 19:31:21 UTC
(rev 17949)
@@ -1,21 +0,0 @@
-package org.gnunet.util.scheduler;
-
-import org.gnunet.util.time.AbsoluteTime;
-
-public class Task {
- private TaskCallback cb;
-
- // Unique Task Identifier
- int id;
-
- int prereq_id;
-
- AbsoluteTime timeout;
-
- AbsoluteTime start_time;
-
- int read_fd, write_fd;
-
- int lifeness;
-
-}
Modified: gnunet-java/src/org/gnunet/util/scheduler/TaskContext.java
===================================================================
--- gnunet-java/src/org/gnunet/util/scheduler/TaskContext.java 2011-11-02
19:19:59 UTC (rev 17948)
+++ gnunet-java/src/org/gnunet/util/scheduler/TaskContext.java 2011-11-02
19:31:21 UTC (rev 17949)
@@ -1,5 +1,10 @@
package org.gnunet.util.scheduler;
+
+
+/**
+ * Context information passed to each scheduler task.
+ */
public class TaskContext {
}
Copied: gnunet-java/src/org/gnunet/util/scheduler/TaskInfo.java (from rev
17941, gnunet-java/src/org/gnunet/util/scheduler/Task.java)
===================================================================
--- gnunet-java/src/org/gnunet/util/scheduler/TaskInfo.java
(rev 0)
+++ gnunet-java/src/org/gnunet/util/scheduler/TaskInfo.java 2011-11-02
19:31:21 UTC (rev 17949)
@@ -0,0 +1,23 @@
+package org.gnunet.util.scheduler;
+
+import org.gnunet.util.time.AbsoluteTime;
+
+public class TaskInfo {
+ private TaskCallback cb;
+
+ // Unique Task Identifier
+ int id;
+
+ int prereq_id;
+
+ AbsoluteTime timeout;
+
+ AbsoluteTime start_time;
+
+ int read_fd, write_fd;
+
+ int lifeness;
+
+
+
+}
Modified: gnunet-java/src/org/gnunet/util/time/RelativeTime.java
===================================================================
--- gnunet-java/src/org/gnunet/util/time/RelativeTime.java 2011-11-02
19:19:59 UTC (rev 17948)
+++ gnunet-java/src/org/gnunet/util/time/RelativeTime.java 2011-11-02
19:31:21 UTC (rev 17949)
@@ -59,6 +59,11 @@
throw new UnsupportedOperationException();
}
+ /**
+ * Convert a relative time to a string.
+ *
+ * @return string form of the time (as milliseconds)
+ */
@Override
public String toString() {
throw new UnsupportedOperationException();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17949 - in gnunet-java: . src/org/gnunet/util/network src/org/gnunet/util/scheduler src/org/gnunet/util/time,
gnunet <=