You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
clang format apply
This commit is contained in:
@ -16,10 +16,10 @@
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/***********************************************************************
|
||||
* $Id: $
|
||||
*
|
||||
*
|
||||
***********************************************************************/
|
||||
* $Id: $
|
||||
*
|
||||
*
|
||||
***********************************************************************/
|
||||
/** @file */
|
||||
|
||||
#pragma once
|
||||
@ -39,94 +39,94 @@
|
||||
|
||||
namespace threadpool
|
||||
{
|
||||
|
||||
class PriorityThreadPool
|
||||
{
|
||||
public:
|
||||
public:
|
||||
class Functor
|
||||
{
|
||||
public:
|
||||
virtual ~Functor(){};
|
||||
// as of 12/3/13, all implementors return 0 and -1. -1 will cause
|
||||
// this thread pool to reschedule the job, 0 will throw it away on return.
|
||||
virtual int operator()() = 0;
|
||||
};
|
||||
|
||||
class Functor
|
||||
// typedef boost::function0<int> Functor;
|
||||
|
||||
struct Job
|
||||
{
|
||||
Job() : weight(1), priority(0), id(0)
|
||||
{
|
||||
public:
|
||||
virtual ~Functor() { };
|
||||
// as of 12/3/13, all implementors return 0 and -1. -1 will cause
|
||||
// this thread pool to reschedule the job, 0 will throw it away on return.
|
||||
virtual int operator()() = 0;
|
||||
};
|
||||
}
|
||||
boost::shared_ptr<Functor> functor;
|
||||
uint32_t weight;
|
||||
uint32_t priority;
|
||||
uint32_t id;
|
||||
uint32_t uniqueID;
|
||||
uint32_t stepID;
|
||||
primitiveprocessor::SP_UM_IOSOCK sock;
|
||||
};
|
||||
|
||||
//typedef boost::function0<int> Functor;
|
||||
enum Priority
|
||||
{
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
_COUNT
|
||||
};
|
||||
|
||||
struct Job
|
||||
/*********************************************
|
||||
* ctor/dtor
|
||||
*
|
||||
*********************************************/
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
|
||||
PriorityThreadPool(uint targetWeightPerRun, uint highThreads, uint midThreads, uint lowThreads,
|
||||
uint id = 0);
|
||||
virtual ~PriorityThreadPool();
|
||||
|
||||
void removeJobs(uint32_t id);
|
||||
void addJob(const Job& job, bool useLock = true);
|
||||
void stop();
|
||||
|
||||
/** @brief for use in debugging
|
||||
*/
|
||||
void dump();
|
||||
|
||||
protected:
|
||||
private:
|
||||
struct ThreadHelper
|
||||
{
|
||||
ThreadHelper(PriorityThreadPool* impl, Priority queue) : ptp(impl), preferredQueue(queue)
|
||||
{
|
||||
Job() : weight(1), priority(0), id(0) { }
|
||||
boost::shared_ptr<Functor> functor;
|
||||
uint32_t weight;
|
||||
uint32_t priority;
|
||||
uint32_t id;
|
||||
uint32_t uniqueID;
|
||||
uint32_t stepID;
|
||||
primitiveprocessor::SP_UM_IOSOCK sock;
|
||||
};
|
||||
|
||||
enum Priority
|
||||
}
|
||||
void operator()()
|
||||
{
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
_COUNT
|
||||
};
|
||||
ptp->threadFcn(preferredQueue);
|
||||
}
|
||||
PriorityThreadPool* ptp;
|
||||
Priority preferredQueue;
|
||||
};
|
||||
|
||||
/*********************************************
|
||||
* ctor/dtor
|
||||
*
|
||||
*********************************************/
|
||||
explicit PriorityThreadPool();
|
||||
explicit PriorityThreadPool(const PriorityThreadPool&);
|
||||
PriorityThreadPool& operator=(const PriorityThreadPool&);
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
Priority pickAQueue(Priority preference);
|
||||
void threadFcn(const Priority preferredQueue) throw();
|
||||
void sendErrorMsg(uint32_t id, uint32_t step, primitiveprocessor::SP_UM_IOSOCK sock);
|
||||
|
||||
PriorityThreadPool(uint targetWeightPerRun, uint highThreads, uint midThreads,
|
||||
uint lowThreads, uint id = 0);
|
||||
virtual ~PriorityThreadPool();
|
||||
|
||||
void removeJobs(uint32_t id);
|
||||
void addJob(const Job& job, bool useLock = true);
|
||||
void stop();
|
||||
|
||||
/** @brief for use in debugging
|
||||
*/
|
||||
void dump();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
struct ThreadHelper
|
||||
{
|
||||
ThreadHelper(PriorityThreadPool* impl, Priority queue) : ptp(impl), preferredQueue(queue) { }
|
||||
void operator()()
|
||||
{
|
||||
ptp->threadFcn(preferredQueue);
|
||||
}
|
||||
PriorityThreadPool* ptp;
|
||||
Priority preferredQueue;
|
||||
};
|
||||
|
||||
explicit PriorityThreadPool();
|
||||
explicit PriorityThreadPool(const PriorityThreadPool&);
|
||||
PriorityThreadPool& operator=(const PriorityThreadPool&);
|
||||
|
||||
Priority pickAQueue(Priority preference);
|
||||
void threadFcn(const Priority preferredQueue) throw();
|
||||
void sendErrorMsg(uint32_t id, uint32_t step, primitiveprocessor::SP_UM_IOSOCK sock);
|
||||
|
||||
std::list<Job> jobQueues[3]; // higher indexes = higher priority
|
||||
uint32_t threadCounts[3];
|
||||
uint32_t defaultThreadCounts[3];
|
||||
boost::mutex mutex;
|
||||
boost::condition newJob;
|
||||
boost::thread_group threads;
|
||||
bool _stop;
|
||||
uint32_t weightPerRun;
|
||||
volatile uint id; // prevent it from being optimized out
|
||||
std::list<Job> jobQueues[3]; // higher indexes = higher priority
|
||||
uint32_t threadCounts[3];
|
||||
uint32_t defaultThreadCounts[3];
|
||||
boost::mutex mutex;
|
||||
boost::condition newJob;
|
||||
boost::thread_group threads;
|
||||
bool _stop;
|
||||
uint32_t weightPerRun;
|
||||
volatile uint id; // prevent it from being optimized out
|
||||
};
|
||||
|
||||
} // namespace threadpool
|
||||
|
||||
} // namespace threadpool
|
||||
|
Reference in New Issue
Block a user