Boost logo

Boost-Commit :

From: hinnant_at_[hidden]
Date: 2007-12-15 20:23:39


Author: hinnant
Date: 2007-12-15 20:23:38 EST (Sat, 15 Dec 2007)
New Revision: 42091
URL: http://svn.boost.org/trac/boost/changeset/42091

Log:
An example showing how to call pthread_mutex_setprioceiling without the native_handle facility.

Added:
   sandbox/committee/LWG/examples/native_handle3.cpp (contents, props changed)

Added: sandbox/committee/LWG/examples/native_handle3.cpp
==============================================================================
--- (empty file)
+++ sandbox/committee/LWG/examples/native_handle3.cpp 2007-12-15 20:23:38 EST (Sat, 15 Dec 2007)
@@ -0,0 +1,22 @@
+// Example of native_handle2.cpp being done without the native_handle() facility
+// We've turned a compile time error into a run time error
+
+#include <mutex>
+#include <pthread.h>
+
+template <class Mutex>
+int
+mutex_set_priority_ceiling(Mutex& mut, int priority)
+{
+ int old_priority;
+ pthread_mutex_setprioceiling((pthread_mutex_t*)&mut, priority, &old_priority);
+ return old_priority;
+}
+
+int main()
+{
+ std::mutex mut1;
+ mutex_set_priority_ceiling(mut1, 3); // ok on Mac OS X
+ std::timed_mutex mut2;
+ mutex_set_priority_ceiling(mut2, 3); // run time error on Mac OS X
+};


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk