diff options
author | bertrand <Bertrand.Guiheneuf@aful.org> | 1999-09-17 06:26:03 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-09-17 06:26:03 +0800 |
commit | 63039bb99edd9f8c7aea9ef4ce8700d713b01354 (patch) | |
tree | dc00b13ddd4399787049b6fac9adce7b25da81c4 | |
parent | c6da2725e05030af92353147a37a5f559e5f3a42 (diff) | |
download | gsoc2013-evolution-63039bb99edd9f8c7aea9ef4ce8700d713b01354.tar gsoc2013-evolution-63039bb99edd9f8c7aea9ef4ce8700d713b01354.tar.gz gsoc2013-evolution-63039bb99edd9f8c7aea9ef4ce8700d713b01354.tar.bz2 gsoc2013-evolution-63039bb99edd9f8c7aea9ef4ce8700d713b01354.tar.lz gsoc2013-evolution-63039bb99edd9f8c7aea9ef4ce8700d713b01354.tar.xz gsoc2013-evolution-63039bb99edd9f8c7aea9ef4ce8700d713b01354.tar.zst gsoc2013-evolution-63039bb99edd9f8c7aea9ef4ce8700d713b01354.zip |
New object. Operation queue. Meant to be used in non-blocking proxy
1999-09-17 bertrand <Bertrand.Guiheneuf@aful.org>
* camel/camel-op-queue.h:
* camel/camel-op-queue.c:
New object. Operation queue. Meant to be used in
non-blocking proxy objects.
svn path=/trunk/; revision=1231
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | camel/Makefile.am | 2 | ||||
-rw-r--r-- | camel/camel-folder-pt-proxy.c | 39 | ||||
-rw-r--r-- | camel/camel-op-queue.c | 89 | ||||
-rw-r--r-- | camel/camel-op-queue.h | 61 |
5 files changed, 198 insertions, 0 deletions
@@ -1,3 +1,10 @@ +1999-09-17 bertrand <Bertrand.Guiheneuf@aful.org> + + * camel/camel-op-queue.h: + * camel/camel-op-queue.c: + New object. Operation queue. Meant to be used in + non-blocking proxy objects. + 1999-09-14 bertrand <Bertrand.Guiheneuf@aful.org> * camel/Makefile.am (libcamel_la_SOURCES): diff --git a/camel/Makefile.am b/camel/Makefile.am index d9f492bf35..322f096e76 100644 --- a/camel/Makefile.am +++ b/camel/Makefile.am @@ -25,6 +25,7 @@ libcamel_la_SOURCES = \ camel-mime-part.c \ camel-mime-part-utils.c \ camel-multipart.c \ + camel-op-queue.c \ camel-provider.c \ camel-recipient.c \ camel-service.c \ @@ -57,6 +58,7 @@ libcamelinclude_HEADERS = \ camel-mime-part.h \ camel-mime-part-utils.h \ camel-multipart.h \ + camel-op-queue.h \ camel-provider.h \ camel-recipient.h \ camel-service.h \ diff --git a/camel/camel-folder-pt-proxy.c b/camel/camel-folder-pt-proxy.c index 1e7bf4ffa0..0d7bc3c957 100644 --- a/camel/camel-folder-pt-proxy.c +++ b/camel/camel-folder-pt-proxy.c @@ -20,6 +20,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ + +/* FIXME : + * + * the current implementation lauches requests + * on the real folder without bothering on wether + * the global mutex (folder->mutex) is locked or + * not. + * This means that you could have 100 threads + * waiting for the mutex at the same time. + * This is not really a bug, more a nasty feature ;) + * + * This will be solved when the CORBA proxy is + * written, as we will need to queue the requests + * on the client side. The same queue mechanism + * will be used for the pthread proxy + * + */ + + + #include <config.h> #include "camel-folder-pt-proxy.h" #include "camel-log.h" @@ -154,6 +174,10 @@ _finalize (GtkObject *object) } + + +/* folder->init_with_store implementation */ + typedef struct { CamelFolder *folder; CamelStore *parent_store; @@ -168,6 +192,10 @@ _async_init_with_store (_InitStoreParam *param) proxy_folder = CAMEL_FOLDER_PT_PROXY (folder); real_folder = proxy_folder->real_folder; + + /* we may block here but we are actually in a + * separate thread, so no problem + */ g_static_mutex_lock (&(proxy_folder->mutex)); CF_CLASS (real_folder)->init_with_store (real_folder, param->parent_store); @@ -183,10 +211,16 @@ _init_with_store (CamelFolder *folder, CamelStore *parent_store) _InitStoreParam *param; pthread_t init_store_thread; + /* param will be freed in _async_init_with_store */ param = g_new (_InitStoreParam, 1); param->folder = folder; param->parent_store = parent_store; + /* + * call _async_init_with_store in a separate thread + * the thread may block on a mutex, but not the main + * thread. + */ pthread_create (&init_store_thread, NULL , (thread_call_func)_async_init_with_store, param); } @@ -194,6 +228,11 @@ _init_with_store (CamelFolder *folder, CamelStore *parent_store) +/* folder->open implementation */ +typedef struct { + CamelFolder *folder; + CamelFolderOpenMode mode; +} _openFolderParam; static void _open (CamelFolder *folder, CamelFolderOpenMode mode) diff --git a/camel/camel-op-queue.c b/camel/camel-op-queue.c new file mode 100644 index 0000000000..5549a40de1 --- /dev/null +++ b/camel/camel-op-queue.c @@ -0,0 +1,89 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#include "camel-op-queue.h" + + + +/** + * camel_op_queue_new: create a new operation queue + * + * Create a new operation queue. + * + * Return value: the newly allcated object + **/ +CamelOpQueue * +camel_op_queue_new () +{ + CamelOpQueue *op_queue; + op_queue = g_new (CamelOpQueue, 1); + op_queue->ops_tail = NULL; + op_queue->ops_head = NULL; + +} + + +/** + * camel_op_queue_push_op: Add an operation to the queue + * @queue: queue object + * @op: operation to add + * + * Add an operation to an operation queue. + * The queue is a FIFO queue. + **/ +void +camel_op_queue_push_op (CamelOpQueue *queue, CamelOp *op) +{ + GList *new_op; + + g_assert (queue); + + if (!queue->ops_tail) { + queue->ops_head = g_list_prepend (NULL, op); + queue->ops_tail = queue->ops_head; + } else + queue->ops_head = g_list_prepend (queue->ops_head, op); + +} + + +/** + * camel_op_queue_pop_op: Pop the next operation pending in the queue + * @queue: queue object + * + * Pop the next operation pending in the queue. + * + * Return value: + **/ +CamelOp * +camel_op_queue_pop_op (CamelOpQueue *queue) +{ + GList *op; + + g_assert (queue); + + op = queue->ops_tail; + queue->ops_tail = queue->ops_tail->prev; + + return op; +} + + diff --git a/camel/camel-op-queue.h b/camel/camel-op-queue.h new file mode 100644 index 0000000000..34ee8249a1 --- /dev/null +++ b/camel/camel-op-queue.h @@ -0,0 +1,61 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + + +#ifndef CAMEL_OP_QUEUE_H +#define CAMEL_OP_QUEUE_H 1 + + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus }*/ + +#include <glib.h> + +typedef void (CamelOpFunc)(gpointer param); + +typedef struct { + CamelOpFunc *op_func; + gpointer param; + +} CamelOp; + + +typedef struct +{ + GList *ops_head; + GList *ops_tail; + gint pending_ops; +} CamelOpQueue; + + +/* public methods */ +CamelOpQueue *camel_op_queue_new (); +void camel_op_queue_push_op (CamelOpQueue *queue, CamelOp *op); +CamelOp *camel_op_queue_pop_op (CamelOpQueue *queue); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* CAMEL_OP_QUEUE_H */ + |