summaryrefslogtreecommitdiff
path: root/glib/gthreadpool.c
Commit message (Collapse)AuthorAgeFilesLines
* gthreadpool: set default max_unused_threads and max_idle_time valuesDan Winship2012-07-311-4/+5
| | | | | | | | | | | | | | GThreadPool defaulted to 0 for max_unused_threads (meaning thread-pool threads would exit immediately if there was not already another task waiting for them), and 0 for max_idle_time (meaning unused threads would linger forever, though this is only relevant if you changed max_unused_threads). However, GIOScheduler changed the global defaults to 2 and 15*1000, respectively, arguing that these were more useful defaults. And they are, so let's use them. https://bugzilla.gnome.org/show_bug.cgi?id=661767
* gasyncqueue: deprecate GTimeVal-based methods, add relative-delay onesDan Winship2012-02-131-12/+4
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=669670
* Misc doc formatting fixesMatthias Clasen2011-10-151-2/+2
|
* Rename g_thread_try to g_thread_try_newRyan Lortie2011-10-151-1/+1
|
* g_thread_new: never failRyan Lortie2011-10-131-1/+1
| | | | | Remove the GError argument from g_thread_new() and abort on failure. Introduce g_thread_try() for those who want to handle failure.
* thread: nuke the concept of 'joinable'Ryan Lortie2011-10-131-6/+7
| | | | | | | | And remove the 'joinable' argument from g_thread_new() and g_thread_new_full(). Change the wording in the docs. Clarify expectations for (deprecated) g_thread_create().
* Fix up some doc comments that referred to threads not being enabledDan Winship2011-10-051-1/+1
| | | | (and a few other unrelated comment fixes)
* Deprecate g_thread_init()Ryan Lortie2011-10-041-1/+0
| | | | | | | Move the last few things that needed thread-safe initialisation to a global ctor. https://bugzilla.gnome.org/show_bug.cgi?id=660744
* GMain, ThreadPool: embed GCond in structRyan Lortie2011-10-041-9/+5
| | | | | | | Use an embedded GCond and g_cond_init()/clear() instead of a pointer with g_cond_new() and _free(). https://bugzilla.gnome.org/show_bug.cgi?id=660739
* Add new thread creation APIMatthias Clasen2011-10-021-1/+1
| | | | | | | | | | Deprecate both g_thread_create functions and add g_thread_new() and g_thread_new_full(). The new functions expect a name for the thread. Change GThreadPool, GMainContext and GDBus to create named threads. https://bugzilla.gnome.org/show_bug.cgi?id=660635
* GAsyncQueue: Move private API to a private headerMatthias Clasen2011-10-011-10/+13
|
* GThreadPool: cosmetic cleanupsMatthias Clasen2011-10-011-390/+419
| | | | | Mostly documentation and formatting trivial, but also add boolean return types to GError taking functions.
* Spelling fixesMatthias Clasen2011-08-291-2/+2
| | | | | Spelling fixes in comments and docs, provided by Kjartan Maraas in bug 657336.
* glib: Rewrite gatomic.[ch]Ryan Lortie2011-05-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - remove all inline assembly versions - implement the atomic operations using either GCC intrinsics, the Windows interlocked API or a mutex-based fallback - drop gatomic-gcc.c since these are now defined in the header file. Adjust Makefile.am accordingly. - expand the set of operations: support 'get', 'set', 'compare and exchange', 'add', 'or', and 'xor' for both integers and pointers - deprecate g_atomic_int_exchange_and_add since g_atomic_int_add (as with all the new arithmetic operations) now returns the prior value - unify the use of macros: all functions are now wrapped in macros that perform the proper casts and checks - remove G_GNUC_MAY_ALIAS use; it was never required for the integer operations (since casting between pointers that only vary in signedness of the target is explicitly permitted) and we avoid the need for the pointer operations by using simple 'void *' instead of 'gpointer *' (which caused the 'type-punned pointer' warning) - provide function implementations of g_atomic_int_inc and g_atomic_int_dec_and_test: these were strictly macros before - improve the documentation to make it very clear exactly which types of pointers these operations may be used with - remove a few uses of the now-deprecated g_atomic_int_exchange_and_add - drop initialisation of gatomic from gthread (by using a GStaticMutex instead of a GMutex) - update glib.symbols and documentation sections files Closes #650823 and #650935
* Docs: Changed can not to cannot.Murray Cumming2011-03-241-1/+1
|
* Correct gtk-doc SECTION: syntaxJohan Dahlin2011-02-011-1/+1
| | | | | g-ir-scanner does not allow a space between the : and the section name.
* More include cleanupsMatthias Clasen2010-09-031-1/+6
|
* glib/: fully remove galias hacksRyan Lortie2010-07-071-4/+0
|
* GThreadPool: move docs from tmpl to .cRyan Lortie2010-02-011-0/+50
|
* make this a "const gpointer" rather than a gconstpointer to avoid warningsDan Winship2008-09-261-1/+1
| | | | | | | | | | | | | * glib/gthreadpool.c (wakeup_thread_marker): make this a "const gpointer" rather than a gconstpointer to avoid warnings later * glib/pcre/pcre_ucp_searchfuncs.c: * glib/pcre/pcre_valid_utf8.c: #include "config.h" * glib/tests/printf.c (test_d): fool gcc into not warning about some printf format strings that we know are dubious svn path=/trunk/; revision=7552
* Don't use "wait" as parameter name. (#379207, Christian Biere)Matthias Clasen2006-12-171-5/+5
| | | | | | | | 2006-12-17 Matthias Clasen <mclasen@redhat.com> * glib/gthreadpool.h: * glib/gthreadpool.c (g_thread_pool_free): Don't use "wait" as parameter name. (#379207, Christian Biere)
* Make sure g_thread_pool_stop_unused_threads() actually stops unusedMartyn James Russell2006-04-071-250/+284
| | | | | | | | | | | | | * glib/gthreadpool.c: Make sure g_thread_pool_stop_unused_threads() actually stops unused threads and global limits (like max idle time and max unused threads) can be set without creating a thread pool first. Fixed #335215 (patch from Chris Wilson). * tests/threadpool-test.c: Added two new tests, tests setting global limits before creating a thread pool. The second test makes sure unused threads are actually stopped when using the g_thread_pool_stop_unused_threads().
* Updated the documentation to explain that when the maximum threads is > 1Martyn James Russell2006-03-241-0/+6
| | | | | | | | | | | * glib/gthreadpool.c: Updated the documentation to explain that when the maximum threads is > 1 the sort functionality is not 100% accurate due to the ramdom nature of the scheduler choosing which threads to execute. Fixes bug #334943. * tests/threadpool-test.c: Disabled the debugging by default and fixed the sort test to set the maximum threads to 1 to guarantee the thread entry function is called in order.
* Fix deadlock when signalling the thread which freed a thread poolSebastian Wilhelmi2006-02-151-3/+11
| | | | | | | 2006-02-15 Sebastian Wilhelmi <seppi@seppi.de> * glib/gthreadpool.c: Fix deadlock when signalling the thread which freed a thread pool (#331110, Chris Wilson).
* To avoid deadlocks get rid of the settings G_LOCK. Use theSebastian Wilhelmi2006-01-171-176/+194
| | | | | | | | | | | | | | | 2006-01-17 Sebastian Wilhelmi <seppi@seppi.de> * glib/gthreadpool.c: To avoid deadlocks get rid of the settings G_LOCK. Use the unused_thread_queue lock instead. Change g_thread_pool_thread_proxy such that threads only wait on non-exlusive pools for at most a 1/2 second. Do not reorder tasks due to superfluous tasks. Global tasks wait at most for max-idle-time milliseconds. Make sure, that no task is woken up twice for the same event via a wakeup_serial. This fixes #324228. * tests/threadpool-test.c: Adapt test accordingly. Do not pass invalid NULL into the thread pools. This as well fixes #327290.
* Avoid use of varargs macro. (#325864, Kazuki IWAMOTO)Matthias Clasen2006-01-051-39/+41
| | | | | | | 2006-01-05 Matthias Clasen <mclasen@redhat.com> * glib/gthreadpool.c: Avoid use of varargs macro. (#325864, Kazuki IWAMOTO)
* - Added new API g_thread_pool_get_idle_time() andMartyn James Russell2006-01-031-23/+151
| | | | | | | | | | | | * docs/reference/glib/glib-sections.txt: * glib/glib.symbols: * glib/gthreadpool.[ch]: - Added new API g_thread_pool_get_idle_time() and g_thread_pool_set_idle_time(). (#324228). * tests/threadpool-test.c: - Updated test case to do thread pool sorting, thread pool with no sorting and a thread pool with idle thread timeouts.
* New function to sort tasks pushed into a threadpool. (#324479, MartynMatthias Clasen2005-12-211-9/+70
| | | | | | | | | | | 2005-12-20 Matthias Clasen <mclasen@redhat.com> * glib/glib.symbols: * glib/gthreadpool.h: * glib/gthreadpool.c (g_thread_pool_set_sort_function): New function to sort tasks pushed into a threadpool. (#324479, Martyn Russell) * tests/threadpool-test.c: Test this.
* Remove debugging spewMatthias Clasen2005-07-201-5/+0
|
* Don't get stuck in here if immediate is TRUE. (#310954, Hong Jen Yee)Matthias Clasen2005-07-201-2/+9
| | | | | | | | | | 2005-07-20 Matthias Clasen <mclasen@redhat.com> * glib/gthreadpool.c (g_thread_pool_free): Don't get stuck in here if immediate is TRUE. (#310954, Hong Jen Yee) * tests/threadpool-test.c (main): Test immediate == TRUE.
* Make PLT-reduction work with gcc4, and don't include everything inMatthias Clasen2005-03-141-1/+4
| | | | | | | | | | | | | | | | | 2005-03-13 Matthias Clasen <mclasen@redhat.com> Make PLT-reduction work with gcc4, and don't include everything in galias.h: * glib/glib.symbols: Group symbols by header and source file. * glib/makegalias.pl: Protect definitions by the same preprocessor symbols used to guard the headers. Move the alias declarations to a separate file which is produced when calling makegalias.pl -def * glib/Makefile.am (galiasdef.c): Add a rule to generate this file. * glib/*.c: Include galias.h after the other GLib headers, include galiasdef.c at the bottom.
* Implement the same PLT reduction technique used in GTK+:Matthias Clasen2004-09-161-0/+1
| | | | | | Thu Sep 16 02:03:15 2004 Matthias Clasen <maclas@gmx.de> Implement the same PLT reduction technique used in GTK+:
* Patch from Sven Neumann to make the include order consistent. (#71704)Owen Taylor2002-12-041-0/+3
| | | | | | | Tue Dec 3 20:22:27 2002 Owen Taylor <otaylor@redhat.com> * glib/*.c: Patch from Sven Neumann to make the include order consistent. (#71704)
* Unlock the pool for all threads leaving it. (#78348)glib-2-0-branchpointSebastian Wilhelmi2002-04-131-4/+5
| | | | | | | 2002-04-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * glib/gthreadpool.c (g_thread_pool_thread_proxy): Unlock the pool for all threads leaving it. (#78348)
* Documentation fixes.Matthias Clasen2001-12-121-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | * glib/gconvert.c, glib/grand.c, glib/ghash.c, glib/gthreadpool.c, glib/gtree.c: Documentation fixes. * glib/tmpl/allocators.sgml, glib/tmpl/arrays.sgml, glib/tmpl/arrays_byte.sgml, glib/tmpl/arrays_pointer.sgml, glib/tmpl/caches.sgml, glib/tmpl/completion.sgml, glib/tmpl/conversions.sgml, glib/tmpl/datalist.sgml, glib/tmpl/date.sgml, glib/tmpl/error_reporting.sgml, glib/tmpl/fileutils.sgml, glib/tmpl/hash_tables.sgml, glib/tmpl/hooks.sgml, glib/tmpl/macros.sgml, glib/tmpl/macros_misc.sgml, glib/tmpl/main.sgml, glib/tmpl/markup.sgml, glib/tmpl/memory.sgml, glib/tmpl/memory_chunks.sgml, glib/tmpl/messages.sgml, glib/tmpl/misc_utils.sgml, glib/tmpl/modules.sgml, glib/tmpl/numerical.sgml, glib/tmpl/patterns.sgml, glib/tmpl/queue.sgml, glib/tmpl/shell.sgml, glib/tmpl/spawn.sgml, glib/tmpl/string_utils.sgml, glib/tmpl/thread_pools.sgml, glib/tmpl/threads.sgml, glib/tmpl/timers.sgml, glib/tmpl/trees-binary.sgml, glib/tmpl/trees-nary.sgml, glib/tmpl/type_conversion.sgml, glib/tmpl/unicode.sgml, glib/tmpl/warnings.sgml, glib/tmpl/windows.sgml: Improve markup of examples, general consistency improvements.
* Look for nanosleep function.Sebastian Wilhelmi2001-06-071-11/+3
| | | | | | | | | | | | | | | | | | 2001-06-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * configure.in: Look for nanosleep function. * gtimer.c: Use nanosleep for g_usleep, when found. * gtimer.c, gtimer.h: Add g_time_val_add function. Closes #54271. * gasyncqueue.c: Documentation updates. * gthreadpool.c: Use g_time_val_add now that we have it. * glib/glib-sections.txt, glib/tmpl/date.sgml: Add g_time_val_add. * glib/tmpl/threads.sgml: Updated.
* Renamed g_thread_create to g_thread_create_full and added macroSebastian Wilhelmi2001-05-181-82/+21
| | | | | | | | | | | | | | | | | 2001-05-18 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gthread.c, gthread.h: Renamed g_thread_create to g_thread_create_full and added macro g_thread_create, which omits 'stack_size', 'bound' and 'priority' parameters. Also removed 'bound' from GThread struct. * gthreadpool.h, gthreadpool.c: Adapted GThreadPool to the above changes. GThreadPool lost the 'priority' and 'bound' members. g_thread_pool_new the 'stack_size', 'bound' and 'priority' parameters. * tests/mainloop-test.c, tests/thread-test.c, tests/threadpool-test.c: Adapted to the above changes.
* Renamed 'value' and 'arg' to 'data' and 'thread_func' to 'func' to make itSebastian Wilhelmi2001-05-091-22/+22
| | | | | | | | | | | | | 2001-05-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gthread.c, gthread.h: Renamed 'value' and 'arg' to 'data' and 'thread_func' to 'func' to make it more consistent with the rest of GLib. * gthreadpool.c, gthreadpool.h: Moved 'stack_size' from the public members of GThreadPool to the private ones. Renamed 'thread_func' to 'func' as above. Moved up 'user_data' in g_thead_pool_new argument list and in GThreadPool struct.
* Moved func and arg members from GRealThread to GThread, such that they canSebastian Wilhelmi2001-05-081-7/+9
| | | | | | | | | | | | | | | | 2001-05-08 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gmain.c, gthread.c, gthread.h: Moved func and arg members from GRealThread to GThread, such that they can be accessed by the user. * gthread.c, gthread.h: Due to popular demand (Tim being the populus here ;-) threads now have a 'return value', which is returned by g_thread_join and is either the return of the topmost thread function or the value given to g_thread_exit. * gthreadpool.c, tests/mainloop-test.c, tests/thread-test.c: Adapted to the above change.
* Until now every thread pool always had at least one tread waiting to avoidSebastian Wilhelmi2001-04-171-15/+53
| | | | | | | | | | | | | | 2001-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gthreadpool.c (g_thread_pool_thread_proxy): Until now every thread pool always had at least one tread waiting to avoid switching overhead in case a new task would be added soon after one finished. This however means a big waste of threads, if many mostly inactive thread pools are involved. Now such a waiting thread will only wait for half a second (This value is of course very randomly picked) and go to the global threadpool afterwards. MCVS: ----------------------------------------------------------------------
* Added documentation.Sebastian Wilhelmi2001-04-031-31/+213
| | | | | | | | | | | | 2001-04-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gthreadpool.c: Added documentation. * gthreadpool.c: The global thread pool now also is seperated for bound and unbound threads. Only threads with standard stack size go to the global pool. g_thread_pool_new now protects the global setup of inform_mutex etc. with a lock. Fixed some typos. Unlock the queue after g_thread_pool_wakeup_and_stop_all in the proxy.
* Make max_unused_threads work for -1 as well.Sebastian Wilhelmi2001-02-261-1/+1
| | | | | | | 2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gthreadpool.c (g_thread_pool_thread_proxy): Make max_unused_threads work for -1 as well.
* Add a surrogate for thread priorities using PID niceness for systems withSebastian Wilhelmi2000-11-211-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2000-11-21 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * configure.in: Add a surrogate for thread priorities using PID niceness for systems with no thread priorities and different PIDs for threads of the same process (most notably: Linux). Define G_THREAD_USE_PID_SURROGATE in that case, as used by gthread-posix.c. Also make the system thread bigger by sizeof (long) to contain the thread's PID. * gfileutils.c: Include stdlib.h for mkstemp prototype. * gthread.c: Add priority range checks to the affected functions. * gthreadpool.c: Remove unused variable. * gthread-impl.c, gthread-posix.c, gthread-solaris.c: Removed g_thread_map_priority function in favour of the g_thread_priority_map array. Initialize the array with PRIORITY_{...}_VALUE, if available and interpolate beetween the bounds if .._NORMAL_.. and .._HIGH_.. are not available. * gthread-posix.c: If we should use the PID niceness as a surrogate for thread priorities (G_THREAD_USE_PID_SURROGATE is defined), then disable normal priority handling and use PIDs and setpriority() instead. Depends on the thread to write its PID into the place after the thread id right after thread creation.
* Don't take threads with other priorities into account as changing theSebastian Wilhelmi2000-11-091-26/+3
| | | | | | | | | 2000-11-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gthreadpool.c: Don't take threads with other priorities into account as changing the priority is highly unportable. (Actually using it at all already is unportable, but even sometimes where that works, changing priority is not possible).
* Several minor ANSI C fixes.Martin Baulig2000-09-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 2000-09-29 Martin Baulig <baulig@suse.de> Several minor ANSI C fixes. Added missing casts: * gdate.c (g_date_fill_parse_tokens): `s = (guchar *) str'. * gmain.c (g_idle_dispatch): `func = (GSourceFunc) source_data'. (g_idle_add_full): `(gpointer) function' in call to g_source_add(). * gstrfuncs.c (g_strdown): `s = (guchar *) string' and `return (gchar *) string'. (g_strup): Likewise. (g_strchug): `start = (guchar*) string' in 1st for() argument; `strlen ((gchar *) start)' in call to g_memmove(). * gstring.c (g_string_down): `s = (guchar *) string->str'. (g_string_up): Likewise. * gthreadpool.c (stop_this_thread_marker): `(gpointer) &g_thread_pool_new'. * gunidecomp.h (decomp_table[]): Cast all the strings to `unsigned char *'. Put text following #endif into comments: * gmain.c: here.
* Include gerror.h before it is used for some g_thread_* functions.Sebastian Wilhelmi2000-09-011-16/+45
| | | | | | | | | | | | | | | | | 2000-09-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * glib.h: Include gerror.h before it is used for some g_thread_* functions. * gthread.c, gthreadpool.c, glib.h: Enable error reporting for thread creation, namly for g_thread_create, g_thread_pool_new, g_thread_pool_push and g_thread_pool_set_max_threads. * tests/thread-test.c, tests/threadpool-test.c: Adapted accordingly. * gthread-posix.c (g_thread_create_posix_impl): Use GError to report errors.
* applied patch from Andreas Persenius <ndap@swipnet.se> that updates theTim Janik2000-07-261-3/+3
| | | | | | | | Wed Jul 26 12:59:31 2000 Tim Janik <timj@gtk.org> * *.[hc]: applied patch from Andreas Persenius <ndap@swipnet.se> that updates the license headers to the GNU Lesser General Public License, as well as updating the copyright year to 2000.
* New File implementing an asynchronous queue to be used for asynchronousSebastian Wilhelmi2000-04-281-0/+520
2000-04-28 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gasyncqueue.c: New File implementing an asynchronous queue to be used for asynchronous inter-thread communication. * gthreadpool.c: New File implementing a thread pool to be used for distributing work among several threads. * glib.h: Added the type and function declarations for these two types. * tests/threadpool-test.c: New File implementing a test for the thread pool. This also checks the asynchronous queue underlying the thread pool. * tests/Makefile.am: Changed accordingly.