summaryrefslogtreecommitdiffstats
path: root/src/indexer/indexer-queue.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
commitf7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch)
treea3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/indexer/indexer-queue.h
parentInitial commit. (diff)
downloaddovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz
dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/indexer/indexer-queue.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/indexer/indexer-queue.h b/src/indexer/indexer-queue.h
new file mode 100644
index 0000000..a9d5b9d
--- /dev/null
+++ b/src/indexer/indexer-queue.h
@@ -0,0 +1,72 @@
+#ifndef INDEXER_QUEUE_H
+#define INDEXER_QUEUE_H
+
+#include "indexer.h"
+
+typedef void indexer_queue_callback_t(int status, void *context);
+
+struct indexer_request {
+ struct indexer_request *prev, *next;
+
+ char *username;
+ char *mailbox;
+ char *session_id;
+ unsigned int max_recent_msgs;
+
+ /* index messages in this mailbox */
+ bool index:1;
+ /* optimize this mailbox */
+ bool optimize:1;
+ /* currently indexing this mailbox */
+ bool working:1;
+ /* after indexing is finished, add this request back to the queue and
+ reindex it (i.e. a new indexing request came while we were
+ working.) */
+ bool reindex_head:1;
+ bool reindex_tail:1;
+
+ /* when working finished, call this number of contexts and leave the
+ rest to the reindexing. */
+ unsigned int working_context_idx;
+
+ ARRAY(void *) contexts;
+};
+
+struct indexer_queue *indexer_queue_init(indexer_queue_callback_t *callback);
+void indexer_queue_deinit(struct indexer_queue **queue);
+
+/* The callback is called whenever a new request is added to the queue. */
+void indexer_queue_set_listen_callback(struct indexer_queue *queue,
+ void (*callback)(struct indexer_queue *));
+
+void indexer_queue_append(struct indexer_queue *queue, bool append,
+ const char *username, const char *mailbox,
+ const char *session_id, unsigned int max_recent_msgs,
+ void *context);
+void indexer_queue_append_optimize(struct indexer_queue *queue,
+ const char *username, const char *mailbox,
+ void *context);
+void indexer_queue_cancel_all(struct indexer_queue *queue);
+
+bool indexer_queue_is_empty(struct indexer_queue *queue);
+unsigned int indexer_queue_count(struct indexer_queue *queue);
+
+/* Return the next request from the queue, without removing it. */
+struct indexer_request *indexer_queue_request_peek(struct indexer_queue *queue);
+/* Remove the next request from the queue. You must call
+ indexer_queue_request_finish() to free its memory. */
+void indexer_queue_request_remove(struct indexer_queue *queue);
+/* Give a status update about how far the indexing is going on. */
+void indexer_queue_request_status(struct indexer_queue *queue,
+ struct indexer_request *request,
+ int percentage);
+/* Move the next request to the end of the queue. */
+void indexer_queue_move_head_to_tail(struct indexer_queue *queue);
+/* Start working on a request */
+void indexer_queue_request_work(struct indexer_request *request);
+/* Finish the request and free its memory. */
+void indexer_queue_request_finish(struct indexer_queue *queue,
+ struct indexer_request **request,
+ bool success);
+
+#endif