fix indentation

This commit is contained in:
ale_bychuk
2015-03-08 22:04:29 +03:00
parent 662fbc861a
commit 3af35f548c
13 changed files with 1370 additions and 1367 deletions

View File

@@ -46,13 +46,13 @@ class ThreadLocalStorage;
class Foundation_API Thread: private ThreadImpl class Foundation_API Thread: private ThreadImpl
/// This class implements a platform-independent /// This class implements a platform-independent
/// wrapper to an operating system thread. /// wrapper to an operating system thread.
/// ///
/// Every Thread object gets a unique (within /// Every Thread object gets a unique (within
/// its process) numeric thread ID. /// its process) numeric thread ID.
/// Furthermore, a thread can be assigned a name. /// Furthermore, a thread can be assigned a name.
/// The name of a thread can be changed at any time. /// The name of a thread can be changed at any time.
{ {
public: public:
typedef ThreadImpl::TIDImpl TID; typedef ThreadImpl::TIDImpl TID;

View File

@@ -127,11 +127,11 @@ private:
started(false), started(false),
joined(false) joined(false)
{ {
#if defined(POCO_VXWORKS) #if defined(POCO_VXWORKS)
// This workaround is for VxWorks 5.x where // This workaround is for VxWorks 5.x where
// pthread_init() won't properly initialize the thread. // pthread_init() won't properly initialize the thread.
std::memset(&thread, 0, sizeof(thread)); std::memset(&thread, 0, sizeof(thread));
#endif #endif
} }
SharedPtr<Runnable> pRunnableTarget; SharedPtr<Runnable> pRunnableTarget;

View File

@@ -36,9 +36,9 @@ public:
typedef void (*Callable)(void*); typedef void (*Callable)(void*);
#if defined(_DLL) #if defined(_DLL)
typedef DWORD (WINAPI *Entry)(LPVOID); typedef DWORD (WINAPI* Entry)(LPVOID);
#else #else
typedef unsigned (__stdcall *Entry)(void*); typedef unsigned (__stdcall* Entry)(void*);
#endif #endif
enum Priority enum Priority

View File

@@ -39,7 +39,7 @@ class Foundation_API ThreadImpl
public: public:
typedef DWORD TIDImpl; typedef DWORD TIDImpl;
typedef void (*Callable)(void*); typedef void (*Callable)(void*);
typedef DWORD (WINAPI *Entry)(LPVOID); typedef DWORD (WINAPI* Entry)(LPVOID);
enum Priority enum Priority
{ {

View File

@@ -39,11 +39,10 @@
// Block SIGPIPE in main thread. // Block SIGPIPE in main thread.
// //
#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS) #if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
namespace namespace {
class SignalBlocker
{ {
class SignalBlocker public:
{
public:
SignalBlocker() SignalBlocker()
{ {
sigset_t sset; sigset_t sset;
@@ -54,9 +53,9 @@ namespace
~SignalBlocker() ~SignalBlocker()
{ {
} }
}; };
static SignalBlocker signalBlocker; static SignalBlocker signalBlocker;
} }
#endif #endif
@@ -64,16 +63,15 @@ namespace
#if defined(POCO_POSIX_DEBUGGER_THREAD_NAMES) #if defined(POCO_POSIX_DEBUGGER_THREAD_NAMES)
namespace namespace {
void setThreadName(pthread_t thread, const char* threadName)
{ {
void setThreadName(pthread_t thread, const char* threadName)
{
# if (POCO_OS == POCO_OS_MAC_OS_X) # if (POCO_OS == POCO_OS_MAC_OS_X)
pthread_setname_np(threadName); // __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2) pthread_setname_np(threadName); // __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
# else # else
pthread_setname_np(thread, threadName); pthread_setname_np(thread, threadName);
# endif # endif
} }
} }
@@ -109,7 +107,8 @@ void ThreadImpl::setPriorityImpl(int prio)
_pData->policy = SCHED_OTHER; _pData->policy = SCHED_OTHER;
if (isRunningImpl()) if (isRunningImpl())
{ {
struct sched_param par; struct MyStruct struct sched_param par;
struct MyStruct
{ {
}; };
@@ -173,7 +172,7 @@ void ThreadImpl::setStackSizeImpl(int size)
#if defined(POCO_OS_FAMILY_BSD) #if defined(POCO_OS_FAMILY_BSD)
// we must round up to a multiple of the memory page size // we must round up to a multiple of the memory page size
const int STACK_PAGE_SIZE = 4096; const int STACK_PAGE_SIZE = 4096;
size = ((size + STACK_PAGE_SIZE - 1)/STACK_PAGE_SIZE)*STACK_PAGE_SIZE; size = ((size + STACK_PAGE_SIZE - 1) / STACK_PAGE_SIZE) * STACK_PAGE_SIZE;
#endif #endif
#if !defined(POCO_ANDROID) #if !defined(POCO_ANDROID)
if (size < PTHREAD_STACK_MIN) if (size < PTHREAD_STACK_MIN)
@@ -220,9 +219,10 @@ void ThreadImpl::setAffinityImpl(unsigned cpu)
yieldImpl(); yieldImpl();
} }
unsigned ThreadImpl::getAffinityImpl() const { unsigned ThreadImpl::getAffinityImpl() const
unsigned cpuSet = 0; {
unsigned cpuCount = Environment::processorCount(); unsigned cpuSet = 0;
unsigned cpuCount = Environment::processorCount();
#if defined (POCO_OS_FAMILY_UNIX) && POCO_OS != POCO_OS_MAC_OS_X #if defined (POCO_OS_FAMILY_UNIX) && POCO_OS != POCO_OS_MAC_OS_X
#ifdef HAVE_PTHREAD_SETAFFINITY_NP #ifdef HAVE_PTHREAD_SETAFFINITY_NP
cpu_set_t cpuset; cpu_set_t cpuset;
@@ -234,8 +234,10 @@ unsigned cpuCount = Environment::processorCount();
if (pthread_getaffinity_np(_pData->thread, &cpuset) != 0) if (pthread_getaffinity_np(_pData->thread, &cpuset) != 0)
throw SystemException("Failed to get affinity", errno); throw SystemException("Failed to get affinity", errno);
#endif #endif
for (unsigned i = 0; i < cpuCount; i++) { for (unsigned i = 0; i < cpuCount; i++)
if (CPU_ISSET(i, &cpuset)) { {
if (CPU_ISSET(i, &cpuset))
{
cpuSet = i; cpuSet = i;
break; break;
} }
@@ -255,7 +257,8 @@ unsigned cpuCount = Environment::processorCount();
(thread_policy_t)&policy, (thread_policy_t)&policy,
&count, &count,
&get_default); &get_default);
if (ret != KERN_SUCCESS) { if (ret != KERN_SUCCESS)
{
throw SystemException("Failed to get affinity", errno); throw SystemException("Failed to get affinity", errno);
} }
cpuSet = policy.affinity_tag; cpuSet = policy.affinity_tag;
@@ -357,16 +360,16 @@ void ThreadImpl::sleepImpl(long milliseconds)
// This is specific to DECThreads // This is specific to DECThreads
struct timespec interval; struct timespec interval;
interval.tv_sec = milliseconds / 1000; interval.tv_sec = milliseconds / 1000;
interval.tv_nsec = (milliseconds % 1000)*1000000; interval.tv_nsec = (milliseconds % 1000) * 1000000;
pthread_delay_np(&interval); pthread_delay_np(&interval);
#elif POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_QNX || POCO_OS == POCO_OS_VXWORKS #elif POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_QNX || POCO_OS == POCO_OS_VXWORKS
Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds)); Poco::Timespan remainingTime(1000 * Poco::Timespan::TimeDiff(milliseconds));
int rc; int rc;
do do
{ {
struct timespec ts; struct timespec ts;
ts.tv_sec = (long) remainingTime.totalSeconds(); ts.tv_sec = (long) remainingTime.totalSeconds();
ts.tv_nsec = (long) remainingTime.useconds()*1000; ts.tv_nsec = (long) remainingTime.useconds() * 1000;
Poco::Timestamp start; Poco::Timestamp start;
rc = ::nanosleep(&ts, 0); rc = ::nanosleep(&ts, 0);
if (rc < 0 && errno == EINTR) if (rc < 0 && errno == EINTR)
@@ -382,7 +385,7 @@ void ThreadImpl::sleepImpl(long milliseconds)
while (remainingTime > 0 && rc < 0 && errno == EINTR); while (remainingTime > 0 && rc < 0 && errno == EINTR);
if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): nanosleep() failed"); if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): nanosleep() failed");
#else #else
Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds)); Poco::Timespan remainingTime(1000 * Poco::Timespan::TimeDiff(milliseconds));
int rc; int rc;
do do
{ {
@@ -458,11 +461,11 @@ int ThreadImpl::mapPrio(int prio, int policy)
case PRIO_LOWEST_IMPL: case PRIO_LOWEST_IMPL:
return pmin; return pmin;
case PRIO_LOW_IMPL: case PRIO_LOW_IMPL:
return pmin + (pmax - pmin)/4; return pmin + (pmax - pmin) / 4;
case PRIO_NORMAL_IMPL: case PRIO_NORMAL_IMPL:
return pmin + (pmax - pmin)/2; return pmin + (pmax - pmin) / 2;
case PRIO_HIGH_IMPL: case PRIO_HIGH_IMPL:
return pmin + 3*(pmax - pmin)/4; return pmin + 3 * (pmax - pmin) / 4;
case PRIO_HIGHEST_IMPL: case PRIO_HIGHEST_IMPL:
return pmax; return pmax;
default: default:
@@ -478,7 +481,7 @@ int ThreadImpl::reverseMapPrio(int prio, int policy)
{ {
int pmin = getMinOSPriorityImpl(policy); int pmin = getMinOSPriorityImpl(policy);
int pmax = getMaxOSPriorityImpl(policy); int pmax = getMaxOSPriorityImpl(policy);
int normal = pmin + (pmax - pmin)/2; int normal = pmin + (pmax - pmin) / 2;
if (prio == pmax) if (prio == pmax)
return PRIO_HIGHEST_IMPL; return PRIO_HIGHEST_IMPL;
if (prio > normal) if (prio > normal)

View File

@@ -23,26 +23,25 @@
#if defined(POCO_WIN32_DEBUGGER_THREAD_NAMES) #if defined(POCO_WIN32_DEBUGGER_THREAD_NAMES)
namespace namespace {
/// See <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>
/// and <http://blogs.msdn.com/b/stevejs/archive/2005/12/19/505815.aspx> for
/// more information on the code below.
const DWORD MS_VC_EXCEPTION = 0x406D1388;
#pragma pack(push,8)
typedef struct tagTHREADNAME_INFO
{ {
/// See <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>
/// and <http://blogs.msdn.com/b/stevejs/archive/2005/12/19/505815.aspx> for
/// more information on the code below.
const DWORD MS_VC_EXCEPTION = 0x406D1388;
#pragma pack(push,8)
typedef struct tagTHREADNAME_INFO
{
DWORD dwType; // Must be 0x1000. DWORD dwType; // Must be 0x1000.
LPCSTR szName; // Pointer to name (in user addr space). LPCSTR szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread). DWORD dwThreadID; // Thread ID (-1=caller thread).
DWORD dwFlags; // Reserved for future use, must be zero. DWORD dwFlags; // Reserved for future use, must be zero.
} THREADNAME_INFO; } THREADNAME_INFO;
#pragma pack(pop) #pragma pack(pop)
void setThreadName(DWORD dwThreadID, const char* threadName) void setThreadName(DWORD dwThreadID, const char* threadName)
{ {
THREADNAME_INFO info; THREADNAME_INFO info;
info.dwType = 0x1000; info.dwType = 0x1000;
info.szName = threadName; info.szName = threadName;
@@ -56,7 +55,7 @@ namespace
__except (EXCEPTION_CONTINUE_EXECUTION) __except (EXCEPTION_CONTINUE_EXECUTION)
{ {
} }
} }
} }
@@ -107,12 +106,14 @@ void ThreadImpl::setAffinityImpl(unsigned cpu)
{ {
DWORD mask = 1; DWORD mask = 1;
mask <<= cpu; mask <<= cpu;
if (SetThreadAffinityMask(_thread, mask) == 0) { if (SetThreadAffinityMask(_thread, mask) == 0)
{
throw SystemException("Failed to set affinity"); throw SystemException("Failed to set affinity");
} }
} }
unsigned ThreadImpl::getAffinityImpl() const { unsigned ThreadImpl::getAffinityImpl() const
{
throw Poco::NotImplementedException("Get thread affinity not supported on this system"); throw Poco::NotImplementedException("Get thread affinity not supported on this system");
} }

View File

@@ -20,7 +20,6 @@
#include "Poco/Timestamp.h" #include "Poco/Timestamp.h"
#include "Poco/Timespan.h" #include "Poco/Timespan.h"
#include "Poco/Environment.h" #include "Poco/Environment.h"
//#include <iostream>
#if defined(__sun) && defined(__SVR4) && !defined(__EXTENSIONS__) #if defined(__sun) && defined(__SVR4) && !defined(__EXTENSIONS__)
#define __EXTENSIONS__ #define __EXTENSIONS__
#endif #endif

View File

@@ -8,15 +8,15 @@ rm -rf cmake-build
mkdir cmake-build mkdir cmake-build
cd cmake-build cd cmake-build
cmake ../. -DCMAKE_BUILD_TYPE=Debug $1 $2 $3 $4 $5 cmake ../. -DCMAKE_INSTALL_PREFIX=/opt/devel -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON -G "Sublime Text 2 - Unix Makefiles" $1 $2 $3 $4 $5
make -j3 make -j8
make install sudo make install
rm -rf CMakeCache.txt #rm -rf CMakeCache.txt
cmake ../. -DCMAKE_BUILD_TYPE=Release $1 $2 $3 $4 $5 #cmake ../. -DCMAKE_INSTALL_PREFIX=/opt/devel -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON $1 $2 $3 $4 $5
make -j3 #make -j8
make install #sudo make install
cd .. cd ..