From: Christian Grothoff Date: Sun, 4 Mar 2012 21:07:31 +0000 (+0000) Subject: -add priorities to download queue X-Git-Tag: initial-import-from-subversion-38251~14451 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=237a4538616beadd40d3e918ad4b6597b4eb8561;p=oweals%2Fgnunet.git -add priorities to download queue --- diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index 1df9b2e0a..64f55e344 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c @@ -145,11 +145,13 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param stop function to call to pause the job, or on dequeue (if the job was running) * @param cls closure for start and stop * @param blocks number of blocks this jobs uses + * @param priority how important is this download * @return queue handle */ struct GNUNET_FS_QueueEntry * GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_FS_QueueStart start, - GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks) + GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks, + enum GNUNET_FS_QueuePriority priority) { struct GNUNET_FS_QueueEntry *qe; @@ -160,6 +162,7 @@ GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_FS_QueueStart start, qe->cls = cls; qe->queue_time = GNUNET_TIME_absolute_get (); qe->blocks = blocks; + qe->priority = priority; GNUNET_CONTAINER_DLL_insert_after (h->pending_head, h->pending_tail, h->pending_tail, qe); if (h->queue_job != GNUNET_SCHEDULER_NO_TASK) diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h index de66ac661..154e63893 100644 --- a/src/fs/fs_api.h +++ b/src/fs/fs_api.h @@ -417,6 +417,24 @@ typedef void (*GNUNET_FS_QueueStart) (void *cls, typedef void (*GNUNET_FS_QueueStop) (void *cls); + +/** + * Priorities for the queue. + */ +enum GNUNET_FS_QueuePriority + { + /** + * This is a probe (low priority). + */ + GNUNET_FS_QUEUE_PRIORITY_PROBE, + + /** + * Default priority. + */ + GNUNET_FS_QUEUE_PRIORITY_NORMAL + }; + + /** * Entry in the job queue. */ @@ -478,6 +496,11 @@ struct GNUNET_FS_QueueEntry */ unsigned int blocks; + /** + * How important is this download? + */ + enum GNUNET_FS_QueuePriority priority; + /** * How often have we (re)started this download? */ @@ -599,11 +622,13 @@ struct GNUNET_FS_SearchResult * @param stop function to call to pause the job, or on dequeue (if the job was running) * @param cls closure for start and stop * @param blocks number of blocks this download has + * @param priority how important is this download * @return queue handle */ struct GNUNET_FS_QueueEntry * GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_FS_QueueStart start, - GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks); + GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks, + enum GNUNET_FS_QueuePriority priority); /** diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index b23d14b87..2efdcb019 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -2165,7 +2165,10 @@ GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc) GNUNET_assert (dc->job_queue == NULL); dc->job_queue = GNUNET_FS_queue_ (dc->h, &activate_fs_download, &deactivate_fs_download, - dc, (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE); + dc, (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE, + (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE)) + ? GNUNET_FS_QUEUE_PRIORITY_NORMAL + : GNUNET_FS_QUEUE_PRIORITY_PROBE); }