[beast: 62/95] SFI: remove Birnet threading uses
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 62/95] SFI: remove Birnet threading uses
- Date: Mon, 25 Mar 2013 00:41:42 +0000 (UTC)
commit 41b7c0bfe8b18826967998906327b8a45861866b
Author: Tim Janik <timj gnu org>
Date: Wed Mar 20 03:49:53 2013 +0100
SFI: remove Birnet threading uses
sfi/sfiwrapper.cc | 21 +--------
sfi/sfiwrapper.hh | 94 +---------------------------------------
sfi/tests/misctests.cc | 113 +-----------------------------------------------
3 files changed, 4 insertions(+), 224 deletions(-)
---
diff --git a/sfi/sfiwrapper.cc b/sfi/sfiwrapper.cc
index c586cd0..72768e8 100644
--- a/sfi/sfiwrapper.cc
+++ b/sfi/sfiwrapper.cc
@@ -240,31 +240,14 @@ sfi_url_test_show_with_cookie (const char *url,
{
return Birnet::url_test_show_with_cookie (url, url_title, cookie);
}
+
/* --- cleanup handlers --- */
void
birnet_cleanup_force_handlers (void)
{
return Birnet::cleanup_force_handlers();
}
-/* --- threading API --- */
-SfiThread*
-sfi_thread_run (const gchar *name,
- SfiThreadFunc func,
- gpointer user_data)
-{
- g_return_val_if_fail (name && name[0], NULL);
- SfiThread *thread = sfi_thread_new (name);
- sfi_thread_ref_sink (thread);
- if (sfi_thread_start (thread, func, user_data))
- return thread;
- else
- {
- sfi_thread_unref (thread);
- return NULL;
- }
-}
-/* for the sfi_thread_table initialization to work, Birnet::ThreadTable must not be a reference */
-extern "C" const BirnetThreadTable *sfi_thread_table = &::Birnet::ThreadTable;
+
void
sfi_runtime_problem (char ewran_tag,
const char *domain,
diff --git a/sfi/sfiwrapper.hh b/sfi/sfiwrapper.hh
index baa7d9b..fec62b3 100644
--- a/sfi/sfiwrapper.hh
+++ b/sfi/sfiwrapper.hh
@@ -19,7 +19,6 @@ using Rapicorn::AsyncBlockingQueue;
};
-
/* sfiwrapper.h is a thin C language wrapper around C++ features
* provided by libbirnet.
*/
@@ -160,98 +159,7 @@ bool sfi_url_test_show_with_cookie (const char *url,
const char *cookie);
/* --- cleanup handlers --- */
void birnet_cleanup_force_handlers (void); // FIXME: remove
-/* --- threading API --- */
-typedef BirnetThread SfiThread;
-typedef void (*SfiThreadFunc) (void *user_data);
-typedef BirnetCond SfiCond;
-typedef BirnetMutex SfiMutex;
-typedef BirnetRecMutex SfiRecMutex;
-typedef BirnetThreadState SfiThreadState;
-typedef BirnetThreadInfo SfiThreadInfo;
-#define SFI_THREAD_UNKNOWN BIRNET_THREAD_UNKNOWN
-#define SFI_THREAD_RUNNING BIRNET_THREAD_RUNNING
-#define SFI_THREAD_SLEEPING BIRNET_THREAD_SLEEPING
-#define SFI_THREAD_DISKWAIT BIRNET_THREAD_DISKWAIT
-#define SFI_THREAD_TRACED BIRNET_THREAD_TRACED
-#define SFI_THREAD_PAGING BIRNET_THREAD_PAGING
-#define SFI_THREAD_ZOMBIE BIRNET_THREAD_ZOMBIE
-#define SFI_THREAD_DEAD BIRNET_THREAD_DEAD
-SfiThread* sfi_thread_run (const char *name, /* new + start */
- SfiThreadFunc func,
- gpointer user_data);
-#define SFI_MUTEX_DECLARE_INITIALIZED(name) SFI_MUTEX__DECLARE_INITIALIZED (name)
-#define sfi_mutex_init(mtx) (sfi_thread_table->mutex_init (mtx))
-#define sfi_mutex_lock(mtx) (sfi_thread_table->mutex_lock (mtx))
-#define sfi_mutex_trylock(mtx) (0 == sfi_thread_table->mutex_trylock (mtx))
-#define sfi_mutex_unlock(mtx) (sfi_thread_table->mutex_unlock (mtx))
-#define sfi_mutex_destroy(mtx) (sfi_thread_table->mutex_destroy (mtx))
-#define SFI_REC_MUTEX_DECLARE_INITIALIZED(name) SFI_REC_MUTEX__DECLARE_INITIALIZED (name)
-#define sfi_rec_mutex_init(mtx) (sfi_thread_table->rec_mutex_init (mtx))
-#define sfi_rec_mutex_lock(mtx) (sfi_thread_table->rec_mutex_lock (mtx))
-#define sfi_rec_mutex_trylock(mtx) (0 == sfi_thread_table->rec_mutex_trylock (mtx))
-#define sfi_rec_mutex_unlock(mtx) (sfi_thread_table->rec_mutex_unlock (mtx))
-#define sfi_rec_mutex_destroy(mtx) (sfi_thread_table->rec_mutex_destroy (mtx))
-#define SFI_COND_DECLARE_INITIALIZED(name) SFI_COND__DECLARE_INITIALIZED (name)
-#define sfi_cond_init(cond) (sfi_thread_table->cond_init (cond))
-#define sfi_cond_signal(cond) (sfi_thread_table->cond_signal (cond))
-#define sfi_cond_broadcast(cond) (sfi_thread_table->cond_broadcast (cond))
-#define sfi_cond_wait(cond,mtx) (sfi_thread_table->cond_wait (cond, mtx))
-#define sfi_cond_wait_timed(cond,mtx,usecs) (sfi_thread_table->cond_wait_timed (cond, mtx, usecs))
-#define sfi_cond_destroy(cond) (sfi_thread_table->cond_destroy (cond))
-#define sfi_thread_new(name) (sfi_thread_table->thread_new (name))
-#define sfi_thread_ref(thrd) (sfi_thread_table->thread_ref (thrd))
-#define sfi_thread_ref_sink(thrd) (sfi_thread_table->thread_ref_sink (thrd))
-#define sfi_thread_unref(thrd) (sfi_thread_table->thread_unref (thrd))
-#define sfi_thread_start(thrd,func,udata) (sfi_thread_table->thread_start (thrd, func, udata))
-#define sfi_thread_self() (sfi_thread_table->thread_self ())
-#define sfi_thread_self_pid() (sfi_thread_table->thread_pid (sfi_thread_self()))
-#define sfi_thread_get_pid(thrd) (sfi_thread_table->thread_pid (thrd))
-#define sfi_thread_get_name(thrd) (sfi_thread_table->thread_name (thrd))
-#define sfi_thread_set_name(name) (sfi_thread_table->thread_set_name (name))
-#define sfi_thread_sleep(usecs) (sfi_thread_table->thread_sleep (usecs))
-#define sfi_thread_abort(thrd) (sfi_thread_table->thread_abort (thrd))
-#define sfi_thread_queue_abort(thrd) (sfi_thread_table->thread_queue_abort (thrd))
-#define sfi_thread_aborted() (sfi_thread_table->thread_aborted ())
-#define sfi_thread_get_aborted(thrd) (sfi_thread_table->thread_get_aborted (thrd))
-#define sfi_thread_get_running(thrd) (sfi_thread_table->thread_get_running (thrd))
-#define sfi_thread_wait_for_exit(thrd) (sfi_thread_table->thread_wait_for_exit (thrd))
-#define sfi_thread_yield() (sfi_thread_table->thread_yield ())
-#define sfi_thread_info_collect(thrd) (sfi_thread_table->info_collect (thrd))
-#define sfi_thread_info_free(tinfo) (sfi_thread_table->info_free (tinfo))
-#define sfi_thread_get_qdata(quark) (sfi_thread_table->qdata_get (quark))
-#define sfi_thread_set_qdata_full(q,udat,dstry) (sfi_thread_table->qdata_set (q, udat, dstry))
-#define sfi_thread_set_qdata(quark,udata) (sfi_thread_table->qdata_set (quark, udata, NULL))
-#define sfi_thread_steal_qdata(quark) (sfi_thread_table->qdata_steal (quark))
-#define sfi_atomic_pointer_set(atmc,val) (sfi_thread_table->atomic_pointer_set (atmc, val))
-#define sfi_atomic_pointer_get(atmc) (sfi_thread_table->atomic_pointer_get (atmc))
-#define sfi_atomic_pointer_cas(atmc,oval,nval) (sfi_thread_table->atomic_pointer_cas (atmc, oval, nval))
-#define sfi_atomic_int_set(atmc,val) (sfi_thread_table->atomic_int_set (atmc, val))
-#define sfi_atomic_int_get(atmc) (sfi_thread_table->atomic_int_get (atmc))
-#define sfi_atomic_int_cas(atmc,oval,nval) (sfi_thread_table->atomic_int_cas (atmc, oval, nval))
-#define sfi_atomic_int_add(atmc,diff) (sfi_thread_table->atomic_int_add (atmc, diff))
-#define sfi_atomic_int_swap_add(atmc,diff) (sfi_thread_table->atomic_int_swap_add (atmc, diff))
-#define sfi_atomic_uint_set(atmc,val) (sfi_thread_table->atomic_uint_set (atmc, val))
-#define sfi_atomic_uint_get(atmc) (sfi_thread_table->atomic_uint_get (atmc))
-#define sfi_atomic_uint_cas(atmc,oval,nval) (sfi_thread_table->atomic_uint_cas (atmc, oval, nval))
-#define sfi_atomic_uint_add(atmc,diff) (sfi_thread_table->atomic_uint_add (atmc, diff))
-#define sfi_atomic_uint_swap_add(atmc,diff) (sfi_thread_table->atomic_uint_swap_add (atmc, diff))
-/* --- implementation bits --- */
-extern const BirnetThreadTable *sfi_thread_table;
-#define SFI_MUTEX__DECLARE_INITIALIZED(mutexname) \
- SfiMutex mutexname = { 0 }; \
- static void BIRNET_CONSTRUCTOR \
- BIRNET_CPP_PASTE4 (__sfi_mutex__autoinit, __LINE__, __, mutexname) (void) \
- { sfi_thread_table->mutex_chain4init (&mutexname); }
-#define SFI_REC_MUTEX__DECLARE_INITIALIZED(recmtx) \
- SfiRecMutex recmtx = { { 0 } }; \
- static void BIRNET_CONSTRUCTOR \
- BIRNET_CPP_PASTE4 (__sfi_rec_mutex__autoinit, __LINE__, __, recmtx) (void) \
- { sfi_thread_table->rec_mutex_chain4init (&recmtx); }
-#define SFI_COND__DECLARE_INITIALIZED(condname) \
- SfiCond condname = { 0 }; \
- static void BIRNET_CONSTRUCTOR \
- BIRNET_CPP_PASTE4 (__sfi_cond__autoinit, __LINE__, __, condname) (void) \
- { sfi_thread_table->cond_chain4init (&condname); }
+
#ifndef BIRNET__RUNTIME_PROBLEM
#define BIRNET__RUNTIME_PROBLEM(ErrorWarningReturnAssertNotreach,domain,file,line,funcname,...) \
sfi_runtime_problem (ErrorWarningReturnAssertNotreach, domain, file, line, funcname, __VA_ARGS__)
diff --git a/sfi/tests/misctests.cc b/sfi/tests/misctests.cc
index ab9f266..892b5d5 100644
--- a/sfi/tests/misctests.cc
+++ b/sfi/tests/misctests.cc
@@ -143,35 +143,6 @@ test_com_ports (void)
sfi_com_port_unref (port2);
TDONE ();
}
-static void
-test_thread (gpointer data)
-{
- guint *tdata = (guint*) data;
- *tdata += 1;
- while (!sfi_thread_aborted ())
- sfi_thread_sleep (1);
- TACK ();
-}
-static void
-test_threads (void)
-{
- static BirnetMutex test_mutex;
- guint thread_data = 0;
- BirnetThread *thread;
- gboolean locked;
- TSTART ("Threading");
- sfi_mutex_init (&test_mutex);
- locked = sfi_mutex_trylock (&test_mutex);
- TASSERT (locked);
- sfi_mutex_unlock (&test_mutex);
- sfi_mutex_destroy (&test_mutex);
- thread = sfi_thread_run ("sfi-test-thread", test_thread, &thread_data);
- TASSERT (thread != NULL);
- sfi_thread_abort (thread);
- TASSERT (thread_data > 0);
- sfi_thread_unref (thread);
- TDONE ();
-}
#define SCANNER_ASSERT64(scanner, printout, token, text, svalue) { \
g_scanner_input_text (scanner, text, strlen (text)); \
TASSERT (g_scanner_get_next_token (scanner) == token); \
@@ -532,87 +503,7 @@ test_notes (void)
g_free (error);
TDONE ();
}
-static SFI_MUTEX_DECLARE_INITIALIZED (test_mutex);
-static SFI_REC_MUTEX_DECLARE_INITIALIZED (test_rec_mutex);
-static SFI_COND_DECLARE_INITIALIZED (test_cond);
-static void
-check_thread_wrapper_compilation (void)
-{
- return;
- /* this code doesn't need to run, just to compile */
- BirnetMutex *mtx = NULL;
- BirnetRecMutex *rmtx = NULL;
- BirnetCond *cond = NULL;
- BirnetInt64 usecs = 27;
- bool boolv;
- sfi_mutex_init (mtx);
- sfi_mutex_lock (mtx);
- boolv = sfi_mutex_trylock (mtx);
- TASSERT (boolv == false);
- sfi_mutex_unlock (mtx);
- sfi_mutex_destroy (mtx);
- sfi_rec_mutex_init (rmtx);
- sfi_rec_mutex_lock (rmtx);
- boolv = sfi_rec_mutex_trylock (rmtx);
- sfi_rec_mutex_unlock (rmtx);
- sfi_rec_mutex_destroy (rmtx);
- sfi_cond_init (cond);
- sfi_cond_signal (cond);
- sfi_cond_broadcast (cond);
- sfi_cond_wait (cond, mtx);
- sfi_cond_wait_timed (cond, mtx, usecs);
- sfi_cond_destroy (cond);
- BirnetThread *thrd = NULL;
- const char *name = NULL;
- void *udata = NULL;
- BirnetThreadFunc thread_func = NULL;
- GDestroyNotify dstry = NULL;
- BirnetInt64 stamp = 31;
- BirnetThreadInfo *tinfo;
- thrd = sfi_thread_new (name);
- thrd = sfi_thread_ref (thrd);
- thrd = sfi_thread_ref_sink (thrd);
- sfi_thread_unref (thrd);
- sfi_thread_start (thrd, thread_func, udata);
- thrd = sfi_thread_self ();
- int pid1 = sfi_thread_self_pid ();
- int pid2 = sfi_thread_get_pid (thrd);
- TASSERT (pid1 == pid2);
- name = sfi_thread_get_name (thrd);
- sfi_thread_set_name (name);
- sfi_thread_sleep (usecs);
- sfi_thread_abort (thrd);
- sfi_thread_queue_abort (thrd);
- boolv = sfi_thread_aborted ();
- boolv = sfi_thread_get_aborted (thrd);
- boolv = sfi_thread_get_running (thrd);
- sfi_thread_wait_for_exit (thrd);
- sfi_thread_yield ();
- tinfo = sfi_thread_info_collect (thrd);
- sfi_thread_info_free (tinfo);
- GQuark quark = 0;
- udata = sfi_thread_get_qdata (quark);
- sfi_thread_set_qdata_full (quark, udata, dstry);
- sfi_thread_set_qdata (quark, udata);
- udata = sfi_thread_steal_qdata (quark);
- int diff = +17;
- volatile int iatmc, ival = 3, ioval = 4, inval = 5;
- volatile uint uatmc, uval = 3, uoval = 4, unval = 5;
- volatile void *patmc, *pval = (void*) 1, *poval = (void*) 2, *pnval = (void*) 3;
- sfi_atomic_pointer_set (&patmc, pval);
- pval = sfi_atomic_pointer_get (&patmc);
- boolv = sfi_atomic_pointer_cas (&patmc, poval, pnval);
- sfi_atomic_int_set (&iatmc, ival);
- ival = sfi_atomic_int_get (&iatmc);
- boolv = sfi_atomic_int_cas (&iatmc, ioval, inval);
- sfi_atomic_int_add (&iatmc, diff);
- ival = sfi_atomic_int_swap_add (&iatmc, diff);
- sfi_atomic_uint_set (&uatmc, uval);
- uval = sfi_atomic_uint_get (&uatmc);
- boolv = sfi_atomic_uint_cas (&uatmc, uoval, unval);
- sfi_atomic_uint_add (&uatmc, diff);
- uval = sfi_atomic_uint_swap_add (&uatmc, diff);
-}
+
static void
test_renames (void)
{
@@ -854,7 +745,6 @@ main (int argc,
generate_vmarshal_code ();
return 0;
}
- check_thread_wrapper_compilation ();
test_notes ();
test_time ();
test_renames ();
@@ -864,7 +754,6 @@ main (int argc,
test_typed_serialization (SERIAL_TEST_PSPEC);
test_vmarshals ();
test_com_ports ();
- test_threads ();
test_sfidl_seq ();
test_messages();
test_misc ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]