* POSIX thread functions. POSIX
* barriers are a relatively new
* feature and are not supported on
- * all systems. If the
- * configuration detected the
- * absence of these functions, then
- * barriers will not be available,
- * and creating objects of this
- * class will result in an
- * exception been thrown. The rest
- * of the threading functionality
- * will be available, though.
+ * all systems.
+ *
+ * If the configuration detected
+ * the absence of these functions,
+ * then barriers will not be
+ * available, and creating objects
+ * of this class will result in an
+ * exception been thrown unless the
+ * count given for the parties
+ * waiting for the barrier is equal
+ * to one (as in this case waiting
+ * for the barrier is a
+ * no-operation, and we can
+ * dispense with the POSIX
+ * functions at all). The rest of
+ * the threading functionality will
+ * be available in its full extent,
+ * though, even if POSIX barriers
+ * are not available.
*
* @author Wolfgang Bangerth, 2002
*/
*/
#ifndef DEAL_II_USE_MT_POSIX_NO_BARRIERS
pthread_barrier_t barrier;
+#else
+ unsigned int count;
#endif
};
#else
- PosixThreadBarrier::PosixThreadBarrier (const unsigned int ,
+ PosixThreadBarrier::PosixThreadBarrier (const unsigned int count,
const char *,
void *)
+ : count (count)
{
- AssertThrow (false,
+ // throw an exception unless we
+ // have the special case that a
+ // count of 1 is given, since
+ // then waiting for a barrier is
+ // a no-op, and we don't need the
+ // POSIX functionality
+ AssertThrow (count == 1,
ExcMessage ("Your local POSIX installation does not support\n"
"POSIX barriers. You will not be able to use\n"
"this class, but the rest of the threading\n"
#ifndef DEAL_II_USE_MT_POSIX_NO_BARRIERS
pthread_barrier_destroy (&barrier);
#else
- std::abort ();
+ // unless the barrier is a no-op,
+ // complain again (how did we get
+ // here then?)
+ if (count != 1)
+ std::abort ();
#endif
};
#ifndef DEAL_II_USE_MT_POSIX_NO_BARRIERS
return pthread_barrier_wait (&barrier);
#else
- std::abort ();
- return 1;
+ // in the special case, this
+ // function is a no-op. otherwise
+ // complain about the missing
+ // POSIX functions
+ if (count == 1)
+ return 0;
+ else
+ {
+ std::abort ();
+ return 1;
+ };
#endif
};
<h3>base</h3>
<ol>
+ <li> <p>
+ Extended: Previously, the <code class="class">Threads::PosixThreadBarrier</code>
+ class could not be used at all (they threw exceptions), if your system
+ did not have the respective POSIX functions. This restriction is lifted
+ for the special case that you give one as the number of parties that
+ will be waiting for the barrier: in this case, a barrier is a
+ no-operation, so we do not need assistence from the operating
+ system. This change makes it slightly simpler to write programs in a way
+ such that they run in both single- and multithreaded environments.
+ <br>
+ (WB 2002/09/05)
+ </p>
+
<li> <p>
New: The old class <code class="class">vector2d</code>, implementing a
two-dimensional array of objects is now gone. Instead, there is the new