You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2007/06/17 23:35:57 UTC
svn commit: r548119 - /incubator/stdcxx/trunk/tests/src/thread.cpp
Author: sebor
Date: Sun Jun 17 14:35:56 2007
New Revision: 548119
URL: http://svn.apache.org/viewvc?view=rev&rev=548119
Log:
2007-06-17 Martin Sebor <se...@roguewave.com>
* thread.cpp [!_RWSTD_REENTRANT] (rw_thread_pool): When not reentrant
(in non-thread safe builds) emulated the creation of a single thread
and then waiting for it to finish by simply calling the thread
procedure to simplify the logic in each test.
Modified:
incubator/stdcxx/trunk/tests/src/thread.cpp
Modified: incubator/stdcxx/trunk/tests/src/thread.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/thread.cpp?view=diff&rev=548119&r1=548118&r2=548119
==============================================================================
--- incubator/stdcxx/trunk/tests/src/thread.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/thread.cpp Sun Jun 17 14:35:56 2007
@@ -31,6 +31,7 @@
#include <rw_thread.h>
#include <stddef.h> // for size_t
+#include <string.h> // for memset()
/**************************************************************************/
@@ -381,7 +382,35 @@
// small buffer for thread ids when invoked with (thr_id == 0)
rw_thread_t id_buf [16];
- bool join = 0 == thr_id;
+ const bool join = 0 == thr_id;
+
+#ifndef _RWSTD_REENTRANT
+
+ // when not reentrant/thread safe emulate the creation
+ // of a single thread and then waiting for it to finish
+ // by simply calling the thread procedure
+
+ if (1 == nthrs && join) {
+
+ if (0 == thr_id) {
+ thr_id = id_buf;
+ memset (thr_id, 0, sizeof *thr_id);
+ }
+
+ // when the thr_arg pointer is 0 pass the address
+ // of each thread's id as the argument to thr_proc
+ void* const arg = thr_arg ? thr_arg [0] : (void*)(thr_id);
+
+ void* const thr_result = thr_proc (arg);
+
+ if (thr_arg)
+ thr_arg [0] = thr_result;
+
+ return 0;
+ }
+
+#endif // !_RWSTD_REENTRANT
+
bool delete_ids = false;
if (0 == thr_id) {