Commit Graph

26 Commits

Author SHA1 Message Date
Simon McVittie
d499c53158 threadpool test: Don't leak the thread pool
Detected by AddressSanitizer.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-29 20:26:05 +00:00
Philip Withnall
543a0c4091 tests: Fix unused variable in the threadpool-test
It looks like `continue_timeout` should be returned here, rather than
being set and never read. Spotted by `scan-build`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-30 15:24:08 +00:00
Stef Walter
d10f35310f threadpool-test: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711751
2013-11-11 17:37:48 +01:00
Ryan Lortie
210b1f8b42 Remove a bunch of lingering g_thread_init()
After this patch, there is but one remaining use of g_thread_init(),
which is in tests/slice-threadinit.c, a testcase dedicated to testing
the functionality of gslice across a g_thread_init() boundary.

This testcase is pretty meaningless these days... probably we should
delete it.
2013-05-31 23:03:19 -04:00
Simon McVittie
837db1a026 Fix more warning-addition fallout
I'm normally a big fan of small atomic commits, but I also want to get
things done this afternoon...

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=687441
Reviewed-by: Colin Walters <walters@verbum.org>
2012-11-02 16:27:19 +00:00
Matthias Clasen
373dcaea56 Improve threadpool test coverage 2012-08-18 14:38:53 -04:00
Dan Winship
c37273dccb fix warnings 2012-04-30 09:28:42 -04:00
Matthias Clasen
151756631d Don't use g_thread_foreach in tests 2011-10-02 22:31:45 -04:00
Dan Winship
5bc7729d16 Make threads mandatory
G_THREADS_ENABLED still exists, but is always defined. It is still
possible to use libglib without threads, but gobject (and everything
above it) is now guaranteed to be using threads (as, in fact, it was
before, since it was accidentally impossible to compile with
--disable-threads).

https://bugzilla.gnome.org/show_bug.cgi?id=616754
2011-09-09 12:41:55 -04:00
Matthias Clasen
1b28408b8b Spelling fixes
Spelling fixes in comments and docs, provided by
Kjartan Maraas in bug 657336.
2011-08-29 14:49:32 -04:00
Ryan Lortie
dbd0d63b6b wait longer in threadpool test case
If we are going to fail an assert, wait for a bit longer before doing so
(up to 5 seconds, if needed).

This is a long-standing Debian patch to fix build failures on really
slow machines.
2011-07-20 10:51:16 +02:00
Johan Dahlin
761424465a Include "config.h" instead of <config.h> Command used: find -name
2008-06-21  Johan Dahlin  <jdahlin@async.com.br>

    * *.[ch]: Include "config.h" instead of <config.h>
    Command used:
    find -name \*.[ch]|xargs perl -p -i -e 's/^#include <config.h>/#include "config.h"/g'
    Rubberstamped by Mitch


svn path=/trunk/; revision=7092
2008-06-22 15:10:51 +00:00
Sebastian Wilhelmi
fa7351324a Grab thread_counter_pools LOCK when increasing leftover_task_counter.
2008-01-29  Sebastian Wilhelmi  <wilhelmi@google.com>

	* tests/threadpool-test.c (test_thread_pools): Grab
	thread_counter_pools LOCK when increasing
	leftover_task_counter. Fixes race in test. (#512624, Simon Murray)

svn path=/trunk/; revision=6406
2008-01-29 10:07:07 +00:00
Matthias Clasen
9d3c408fbe Stop unused threads before the last test, to make the test terminate
* tests/threadpool-test.c: Stop unused threads before
        the last test, to make the test terminate reliably.



svn path=/trunk/; revision=5477
2007-05-03 04:48:10 +00:00
Martyn James Russell
eab7250b58 (test_thread_stop_unused): Removed an
assertion which can fail and is not a critical test.
2006-04-07 18:47:33 +00:00
Martyn James Russell
6c6f17133d Make sure g_thread_pool_stop_unused_threads() actually stops unused
* 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().
2006-04-07 09:23:42 +00:00
Martyn James Russell
f0ee594a80 Updated the documentation to explain that when the maximum threads is > 1
* 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.
2006-03-24 15:21:28 +00:00
Sebastian Wilhelmi
f4484f51bf To avoid deadlocks get rid of the settings G_LOCK. Use the
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.
2006-01-17 20:06:27 +00:00
Martyn James Russell
941faa1ca9 - Added new API g_thread_pool_get_idle_time() and
* 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.
2006-01-03 15:09:52 +00:00
Matthias Clasen
700a71f010 New function to sort tasks pushed into a threadpool. (#324479, Martyn
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.
2005-12-21 04:45:56 +00:00
Matthias Clasen
8ac11176ab Don't get stuck in here if immediate is TRUE. (#310954, Hong Jen Yee)
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.
2005-07-20 17:06:02 +00:00
Sebastian Wilhelmi
d81ac5339f Added #undef G_DISABLE_ASSERT and #undef G_LOG_DOMAIN throughout the
2002-07-04  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* tests/*.c: Added #undef G_DISABLE_ASSERT and #undef G_LOG_DOMAIN
	throughout the files, which didn't already have them. (#87312)
2002-07-04 15:19:30 +00:00
Sebastian Wilhelmi
227d18bc46 Renamed g_thread_create to g_thread_create_full and added macro
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.
2001-05-18 08:44:57 +00:00
Sebastian Wilhelmi
e885fe2462 Moved determination of G_THREAD_FLAGS before G_THREAD_LIBS. Check for
2000-09-28  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* configure.in: Moved determination of G_THREAD_FLAGS before
	G_THREAD_LIBS. Check for UnixWare systems and set the right cflags
	and libs there (it needs -Kthread for the native compiler and
	-pthread for gcc). Thanks to Boyd Lynn Gerber <gerberb@zenez.com>
	for the info.

	* configure.in: Fail immediately, when no thread library is found,
	instead of continuing searching for rt libs etc. Changed almost
	all occurances of $enable_threads to $have_threads, as that's,
	what we want.

	* tests/threadpool-test.c: Define vars inside the guard to avoid
	warnings.
2000-09-28 07:54:40 +00:00
Sebastian Wilhelmi
64bbfbb6da Include gerror.h before it is used for some g_thread_* functions.
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.
2000-09-01 13:03:23 +00:00
Sebastian Wilhelmi
1418fe3a6d New File implementing an asynchronous queue to be used for asynchronous
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.
2000-04-28 12:24:53 +00:00