Changeset 3664

Show
Ignore:
Timestamp:
05/14/08 17:17:53
Author:
pvanhoof
Message:

2008-05-14 Philip Van Hoof <pvanhoof@gnome.org>

        • libtinymail-camel/tny-camel-queue.c: Letting the thread wait for

more items instead of exiting

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3663 r3664  
     12008-05-14  Philip Van Hoof <pvanhoof@gnome.org> 
     2 
     3        * libtinymail-camel/tny-camel-queue.c: Letting the thread wait for 
     4        more items instead of exiting 
     5 
    162008-05-13  Rob Taylor  <rob.taylor@codethink.co.uk> 
    27 
     
    484489 
    485490        * Attempt at making mime parsing use the seekable capability of 
    486         streams in stead of copying them in memory. This is experimental! 
     491        streams instead of copying them in memory. This is experimental! 
    487492 
    4884932008-03-04  Philip Van Hoof <pvanhoof@gnome.org> 
     
    906911 
    907912        * Code robustness 
    908         * Changed the account item of a folder to be hard referenced in stead 
     913        * Changed the account item of a folder to be hard referenced instead 
    909914        of weakly 
    910915 
     
    103310382007-12-12  Philip Van Hoof <pvanhoof@gnome.org> 
    10341039 
    1035         * Experimental appending in stead of rewriting the summary.mmap 
     1040        * Experimental appending instead of rewriting the summary.mmap 
    10361041 
    103710422007-12-11  Philip Van Hoof <pvanhoof@gnome.org> 
     
    13341339        observers 
    13351340        * Cyclic references fix. tny_folder_store_add_observer and 
    1336         tny_folder_add_observer no longer add strong references, in stead they 
     1341        tny_folder_add_observer no longer add strong references, instead they 
    13371342        add weak references 
    13381343 
     
    13401345        root folder C, and then move A into B, that A would only become a 
    13411346        subfolder of B after you restart the application. The problem was that 
    1342         A and B got created with _tny_camel_folder_new in stead of the 
     1347        A and B got created with _tny_camel_folder_new instead of the 
    13431348        tny_camel_store_account_factor_folder. This made the observers 
    13441349        infrastructure of the model confuse when a new list of folder was 
     
    13481353 
    13491354        For future, let's be extremely careful not to use 
    1350         _tny_camel_folder_new but in stead to make sure that the factory is 
     1355        _tny_camel_folder_new but instead to make sure that the factory is 
    13511356        always used. 
    13521357 
     
    15261531 
    15271532        * Fixed regression on the regression fix of a few days ago :) 
    1528         * Renamed Maildir filenames to have '!' in stead of '_' or ':' in 
     1533        * Renamed Maildir filenames to have '!' instead of '_' or ':' in 
    15291534        their filenames 
    15301535 
     
    31493154        * Support for tny_header_get_uid on TnyMsg's header instance 
    31503155        * Removed the warning in libtinymail/tny-folder.c: please use the 
    3151         support for DBC in stead. It's specifically designed for this. Read 
     3156        support for DBC instead. It's specifically designed for this. Read 
    31523157        the documentation in building.txt to find out how to enable it. 
    31533158 
     
    47754780        consumption on initial download of both IMAP and NNTP folders. 
    47764781        * libtinymail-gnome-desktop: Default status of the device is now 
    4777         offline in stead of online (for example in case network manager 
     4782        offline instead of online (for example in case network manager 
    47784783        installation was invalid or not found) 
    47794784        * Bugfix reported by Nitin.Mahajan@nokia.com 
     
    47884793 
    47894794        * libtinymail-camel/camel-lite: Allocation of the CamelFolderInfo is 
    4790         now with GSlice in stead of many different malloc ways. This one needs 
     4795        now with GSlice instead of many different malloc ways. This one needs 
    47914796        testing! 
    47924797 
  • trunk/libtinymail-camel/tny-camel-queue-priv.h

    r3102 r3664  
    4646        GList *list; 
    4747        GThread *thread; 
     48        GCond *condition; 
     49        GMutex *mutex; 
     50        gboolean is_waiting; 
    4851        GStaticRecMutex *lock; 
    4952        gboolean stopped, next_uncancel; 
  • trunk/libtinymail-camel/tny-camel-queue.c

    r3499 r3664  
    5252        self->list = NULL; 
    5353        g_static_rec_mutex_unlock (self->lock); 
     54 
     55        g_cond_free (self->condition); 
     56        g_mutex_free (self->mutex); 
    5457 
    5558        /* g_static_rec_mutex_free (self->lock); */ 
     
    167170                GList *first = NULL; 
    168171                QueueItem *item = NULL; 
    169                 gboolean deleted = FALSE
     172                gboolean deleted = FALSE, wait = FALSE
    170173 
    171174                g_static_rec_mutex_lock (queue->lock); 
     
    184187                        queue->current = item; 
    185188                } else 
    186                         queue->stopped = TRUE; 
     189                        wait = TRUE; 
    187190                g_static_rec_mutex_unlock (queue->lock); 
    188191 
     
    234237                queue->current = NULL; 
    235238 
    236                 if (g_list_length (queue->list) == 0) { 
    237                         queue->thread = NULL; 
    238                         queue->stopped = TRUE; 
    239                 } 
     239                if (g_list_length (queue->list) == 0) 
     240                        wait = TRUE; 
    240241                g_static_rec_mutex_unlock (queue->lock); 
    241242 
    242243                if (item) 
    243244                        g_slice_free (QueueItem, item); 
     245 
     246                if (wait) { 
     247                        g_mutex_lock (queue->mutex); 
     248                        queue->is_waiting = TRUE; 
     249                        g_cond_wait (queue->condition, queue->mutex); 
     250                        queue->is_waiting = FALSE; 
     251                        g_mutex_unlock (queue->mutex); 
     252                } 
    244253        } 
    245254 
     
    410419                        queue->stopped = TRUE; 
    411420                } 
     421        } else { 
     422                g_mutex_lock (queue->mutex); 
     423                //if (queue->is_waiting) 
     424                        g_cond_broadcast (queue->condition); 
     425                g_mutex_unlock (queue->mutex); 
    412426        } 
    413427 
     
    465479        TnyCamelQueue *self = (TnyCamelQueue*)instance; 
    466480 
     481        self->is_waiting = FALSE; 
     482        self->mutex = g_mutex_new (); 
     483        self->condition = g_cond_new (); 
    467484        self->account = NULL; 
    468485        self->stopped = TRUE; 
    469486        self->list = NULL; 
     487 
     488        /* We don't use a GThreadPool because we need control over the queued 
     489         * items: we must remove them sometimes for example. */ 
     490 
    470491        self->thread = NULL; 
    471492        self->lock = g_new0 (GStaticRecMutex, 1);