aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-op-queue.c
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-09-18 07:40:06 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-09-18 07:40:06 +0800
commit445b09502f6aabb6359c18acb188e92e97da31f7 (patch)
tree47ead377e2f198570cd4819f3052a1d78d1ffc9a /camel/camel-op-queue.c
parentacd6bafa58cf5fdea4814e51aac175a99894a373 (diff)
downloadgsoc2013-evolution-445b09502f6aabb6359c18acb188e92e97da31f7.tar.gz
gsoc2013-evolution-445b09502f6aabb6359c18acb188e92e97da31f7.tar.zst
gsoc2013-evolution-445b09502f6aabb6359c18acb188e92e97da31f7.zip
new func. Try to exec an operation in a thread or queue it if a thread is
1999-09-18 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-folder-pt-proxy.c (_op_exec_or_plan_for_exec): new func. Try to exec an operation in a thread or queue it if a thread is already busy. * camel/camel-op-queue.c (camel_op_queue_set_service_availability): (camel_op_queue_get_service_availability): new funcs. * camel/camel-op-queue.c (camel_op_new): (camel_op_free): new funcs. Uses glib mem chunks. svn path=/trunk/; revision=1237
Diffstat (limited to 'camel/camel-op-queue.c')
-rw-r--r--camel/camel-op-queue.c67
1 files changed, 65 insertions, 2 deletions
diff --git a/camel/camel-op-queue.c b/camel/camel-op-queue.c
index c58ade9958..d943b8e80b 100644
--- a/camel/camel-op-queue.c
+++ b/camel/camel-op-queue.c
@@ -21,7 +21,8 @@
#include "camel-op-queue.h"
-
+#define NB_OP_CHUNKS 20
+static GMemChunk *op_chunk=NULL;
/**
* camel_op_queue_new: create a new operation queue
@@ -34,6 +35,11 @@ CamelOpQueue *
camel_op_queue_new ()
{
CamelOpQueue *op_queue;
+ if (!op_chunk)
+ op_chunk = g_mem_chunk_create (CamelOp,
+ NB_OP_CHUNKS,
+ G_ALLOC_AND_FREE);
+
op_queue = g_new (CamelOpQueue, 1);
op_queue->ops_tail = NULL;
op_queue->ops_head = NULL;
@@ -104,7 +110,64 @@ camel_op_queue_run_next_op (CamelOpQueue *queue)
if (!op) return FALSE;
/* run the operation */
- op->op_func (op->param);
+ op->func (op->param);
return FALSE;
}
+
+/**
+ * camel_op_queue_set_service_availability: set the service availability for an operation queue
+ * @queue: queue object
+ * @available: availability flag
+ *
+ * set the service availability
+ **/
+void
+camel_op_queue_set_service_availability (CamelOpQueue *queue, gboolean available)
+{
+ queue->service_available = available;
+}
+
+/**
+ * camel_op_queue_get_service_availability: determine if an operation queue service is available
+ * @queue: queue object
+ *
+ * Determine if the service associated to an operation queue is available.
+ *
+ * Return value: service availability.
+ **/
+gboolean
+camel_op_queue_get_service_availability (CamelOpQueue *queue)
+{
+ return queue->service_available;
+}
+
+/**
+ * camel_op_new: return a new CamelOp object
+ *
+ * The obtained object must be destroyed with
+ * camel_op_free ()
+ *
+ * Return value: the newly allocated CamelOp object
+ **/
+CamelOp *
+camel_op_new ()
+{
+ return g_chunk_new (CamelOp, op_chunk);
+}
+
+/**
+ * camel_op_free: free a CamelOp object allocated with camel_op_new
+ * @op: CamelOp object to free
+ *
+ * Free a CamelOp object allocated with camel_op_new ()
+ * this routine won't work with CamelOp objects allocated
+ * with other allocators.
+ **/
+void
+camel_op_free (CamelOp *op)
+{
+ g_chunk_free (op, op_chunk);
+}
+
+