enum GNUNET_SCHEDULER_Priority p);
+/**
+ * Obtain the reason code for why the current task was
+ * started. Will return the same value as
+ * the GNUNET_SCHEDULER_TaskContext's reason field.
+ *
+ * @param sched scheduler to query
+ * @return reason(s) why the current task is run
+ */
+enum GNUNET_SCHEDULER_Reason
+GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched);
+
+
/**
* Cancel the task with the specified identifier.
* The task must not yet have run.
*/
struct Task *pending;
+ /**
+ * ID of the task that is running right now.
+ */
+ struct Task *active_task;
+
/**
* List of tasks ready to run right now,
* grouped by importance.
sched->ready_count--;
sched->current_priority = p;
GNUNET_assert (pos->priority == p);
+ sched->active_task = pos;
tc.sched = sched;
tc.reason = pos->reason;
tc.read_ready = pos->read_set;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Running task: %llu / %p\n", pos->id, pos->callback_cls);
#endif
+ sched->active_task = NULL;
destroy_task (pos);
sched->tasks_run++;
}
}
+/**
+ * Obtain the reason code for why the current task was
+ * started. Will return the same value as
+ * the GNUNET_SCHEDULER_TaskContext's reason field.
+ *
+ * @param sched scheduler to query
+ * @return reason(s) why the current task is run
+ */
+enum GNUNET_SCHEDULER_Reason
+GNUNET_SCHEDULER_get_reason (struct GNUNET_SCHEDULER_Handle *sched)
+{
+ return sched->active_task->reason;
+}
+
/**
* Get information about the current load of this scheduler. Use this