clang-format scheduler

Can easily be reviewed with the git options
--ignore-all-space --word-diff-regex=. -U0
This commit is contained in:
MarcoFalke committed 2020-06-21 06:02:59 -04:00
1 parent fa3d41b5ab
commit fa8337fcdb
2 files changed
+16 -8

No files matched your search

+14 -7
View File
@@ -122,13 +122,15 @@ size_t CScheduler::getQueueInfo(std::chrono::system_clock::time_point &first,
return result; return result;
} }
bool CScheduler::AreThreadsServicingQueue() const { bool CScheduler::AreThreadsServicingQueue() const
{
LOCK(newTaskMutex); LOCK(newTaskMutex);
return nThreadsServicingQueue; return nThreadsServicingQueue;
} }
void SingleThreadedSchedulerClient::MaybeScheduleProcessQueue() { void SingleThreadedSchedulerClient::MaybeScheduleProcessQueue()
{
{ {
LOCK(m_cs_callbacks_pending); LOCK(m_cs_callbacks_pending);
// Try to avoid scheduling too many copies here, but if we // Try to avoid scheduling too many copies here, but if we
@@ -140,7 +142,8 @@ void SingleThreadedSchedulerClient::MaybeScheduleProcessQueue() {
m_pscheduler->schedule(std::bind(&SingleThreadedSchedulerClient::ProcessQueue, this), std::chrono::system_clock::now()); m_pscheduler->schedule(std::bind(&SingleThreadedSchedulerClient::ProcessQueue, this), std::chrono::system_clock::now());
} }
void SingleThreadedSchedulerClient::ProcessQueue() { void SingleThreadedSchedulerClient::ProcessQueue()
{
std::function<void()> callback; std::function<void()> callback;
{ {
LOCK(m_cs_callbacks_pending); LOCK(m_cs_callbacks_pending);
@@ -157,7 +160,8 @@ void SingleThreadedSchedulerClient::ProcessQueue() {
struct RAIICallbacksRunning { struct RAIICallbacksRunning {
SingleThreadedSchedulerClient* instance; SingleThreadedSchedulerClient* instance;
explicit RAIICallbacksRunning(SingleThreadedSchedulerClient* _instance) : instance(_instance) {} explicit RAIICallbacksRunning(SingleThreadedSchedulerClient* _instance) : instance(_instance) {}
~RAIICallbacksRunning() { ~RAIICallbacksRunning()
{
{ {
LOCK(instance->m_cs_callbacks_pending); LOCK(instance->m_cs_callbacks_pending);
instance->m_are_callbacks_running = false; instance->m_are_callbacks_running = false;
@@ -169,7 +173,8 @@ void SingleThreadedSchedulerClient::ProcessQueue() {
callback(); callback();
} }
void SingleThreadedSchedulerClient::AddToProcessQueue(std::function<void ()> func) { void SingleThreadedSchedulerClient::AddToProcessQueue(std::function<void()> func)
{
assert(m_pscheduler); assert(m_pscheduler);
{ {
@@ -179,7 +184,8 @@ void SingleThreadedSchedulerClient::AddToProcessQueue(std::function<void ()> fun
MaybeScheduleProcessQueue(); MaybeScheduleProcessQueue();
} }
void SingleThreadedSchedulerClient::EmptyQueue() { void SingleThreadedSchedulerClient::EmptyQueue()
{
assert(!m_pscheduler->AreThreadsServicingQueue()); assert(!m_pscheduler->AreThreadsServicingQueue());
bool should_continue = true; bool should_continue = true;
while (should_continue) { while (should_continue) {
@@ -189,7 +195,8 @@ void SingleThreadedSchedulerClient::EmptyQueue() {
} }
} }
size_t SingleThreadedSchedulerClient::CallbacksPending() { size_t SingleThreadedSchedulerClient::CallbacksPending()
{
LOCK(m_cs_callbacks_pending); LOCK(m_cs_callbacks_pending);
return m_callbacks_pending.size(); return m_callbacks_pending.size();
} }
+2 -1
View File
@@ -110,7 +110,8 @@ private:
* B() will be able to observe all of the effects of callback A() which executed * B() will be able to observe all of the effects of callback A() which executed
* before it. * before it.
*/ */
class SingleThreadedSchedulerClient { class SingleThreadedSchedulerClient
{
private: private:
CScheduler* m_pscheduler; CScheduler* m_pscheduler;