You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/07/01 20:06:07 UTC
svn commit: r1498614 - in /activemq/activemq-cpp/branches/3.7.x: ./
activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp
Author: tabish
Date: Mon Jul 1 18:06:06 2013
New Revision: 1498614
URL: http://svn.apache.org/r1498614
Log:
fix for: https://issues.apache.org/jira/browse/AMQCPP-498
Modified:
activemq/activemq-cpp/branches/3.7.x/ (props changed)
activemq/activemq-cpp/branches/3.7.x/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp
Propchange: activemq/activemq-cpp/branches/3.7.x/
------------------------------------------------------------------------------
Merged /activemq/activemq-cpp/trunk:r1498612
Modified: activemq/activemq-cpp/branches/3.7.x/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/3.7.x/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp?rev=1498614&r1=1498613&r2=1498614&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/3.7.x/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp (original)
+++ activemq/activemq-cpp/branches/3.7.x/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp Mon Jul 1 18:06:06 2013
@@ -306,17 +306,34 @@ void PlatformThread::initPriorityMapping
////////////////////////////////////////////////////////////////////////////////
void PlatformThread::createNewThread(decaf_thread_t* handle, threadMainMethod threadMain, void* threadArg,
int priority, long long stackSize, long long* threadId) {
-
pthread_attr_t attributes;
- struct sched_param schedData;
+ int schedResult;
+ int schedPolicy;
- pthread_attr_init( &attributes );
- pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_JOINABLE);
+ schedResult = pthread_attr_init(&attributes);
+ if (schedResult != 0) {
+ throw RuntimeException(__FILE__, __LINE__,
+ "Failed to initialize thread attribute, error value is: %d", schedResult);
+ }
- schedData.sched_priority = priority;
- if (pthread_attr_setschedparam(&attributes, &schedData) != 0) {
+ schedResult = pthread_attr_getschedpolicy(&attributes, &schedPolicy);
+ if (schedResult != 0) {
throw RuntimeException(__FILE__, __LINE__,
- "Failed to set new Therad priority to value: %d", schedData.sched_priority);
+ "Failed to get thread scheduling policy, error value is: %d.", schedResult);
+ }
+
+ // only set the priority if it's a policy that allows setting of the priority.
+ if (SCHED_FIFO == schedPolicy || SCHED_RR == schedPolicy) {
+ struct sched_param schedData;
+
+ schedData.sched_priority = priority;
+ schedResult = pthread_attr_setschedparam(&attributes, &schedData);
+ if (schedResult != 0) {
+ throw RuntimeException(__FILE__, __LINE__,
+ "Failed to set new Thread priority to "
+ "value: %d, error value is: %d.",
+ schedData.sched_priority, schedResult);
+ }
}
if (stackSize != -1) {
@@ -331,15 +348,13 @@ void PlatformThread::createNewThread(dec
throw RuntimeException(
__FILE__, __LINE__,
"Failed to create new Thread due to invalid stack size setting: %d.",
- stackSize );
+ stackSize);
}
}
int result = pthread_create(handle, &attributes, threadMain, threadArg);
-
*threadId = (long long)(&handle);
-
- pthread_attr_destroy( &attributes );
+ pthread_attr_destroy(&attributes);
if( result != 0 ) {
throw RuntimeException(