Skip to content

Commit

Permalink
Merge pull request #95 from pr0g/code-update
Browse files Browse the repository at this point in the history
Minor code update
  • Loading branch information
dougbinks committed Jun 11, 2023
2 parents 4001680 + 789a34d commit 31dc31f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
14 changes: 6 additions & 8 deletions src/TaskScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace enki
static const uint32_t gc_MaxStolenPartitions = 1 << gc_PipeSizeLog2;
static const uint32_t gc_CacheLineSize = 64;
// awaiting std::hardware_constructive_interference_size
};
}

// thread_local not well supported yet by C++11 compilers.
#ifdef _MSC_VER
Expand Down Expand Up @@ -161,7 +161,7 @@ namespace
}
}
#else
static void SpinWait( uint32_t spinCount_ )
void SpinWait( uint32_t spinCount_ )
{
while( spinCount_ )
{
Expand Down Expand Up @@ -201,7 +201,7 @@ ENKITS_API void* enki::DefaultAllocFunc( size_t align_, size_t size_, void* user
}
#endif
return pRet;
};
}

ENKITS_API void enki::DefaultFreeFunc( void* ptr_, size_t size_, void* userData_, const char* file_, int line_ )
{
Expand All @@ -211,7 +211,7 @@ ENKITS_API void enki::DefaultFreeFunc( void* ptr_, size_t size_, void* userD
#else
free( ptr_ );
#endif
};
}

bool TaskScheduler::RegisterExternalTaskThread()
{
Expand Down Expand Up @@ -305,8 +305,6 @@ void TaskScheduler::TaskingThreadFunction( const ThreadArgs& args_ )
pTS->m_NumInternalTaskThreadsRunning.fetch_sub( 1, std::memory_order_release );
pTS->m_pThreadDataStore[threadNum].threadState.store( ENKI_THREAD_STATE_STOPPED, std::memory_order_release );
SafeCallback( pTS->m_Config.profilerCallbacks.threadStop, threadNum );
return;

}


Expand Down Expand Up @@ -1119,7 +1117,7 @@ void TaskScheduler::WaitforAll()
case ENKI_THREAD_STATE_WAIT_NEW_TASKS:
case ENKI_THREAD_STATE_STOPPED:
break;
};
}
}
}
if( !otherThreadsRunning )
Expand Down Expand Up @@ -1264,7 +1262,7 @@ TaskScheduler::TaskScheduler()
, m_NumThreads(0)
, m_pThreadDataStore(NULL)
, m_pThreads(NULL)
, m_bRunning(0)
, m_bRunning(false)
, m_NumInternalTaskThreadsRunning(0)
, m_NumThreadsWaitingForNewTasks(0)
, m_NumThreadsWaitingForTaskCompletion(0)
Expand Down
12 changes: 6 additions & 6 deletions src/TaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ namespace enki

private:
friend class TaskScheduler;
void OnDependenciesComplete( TaskScheduler* pTaskScheduler_, uint32_t threadNum_ ) override final;
void OnDependenciesComplete( TaskScheduler* pTaskScheduler_, uint32_t threadNum_ ) final;
uint32_t m_RangeToRun = 1;
};

Expand All @@ -193,7 +193,7 @@ namespace enki
uint32_t threadNum = 0; // thread to run this pinned task on
std::atomic<IPinnedTask*> pNext = {NULL};
private:
void OnDependenciesComplete( TaskScheduler* pTaskScheduler_, uint32_t threadNum_ ) override final;
void OnDependenciesComplete( TaskScheduler* pTaskScheduler_, uint32_t threadNum_ ) final;
};

// TaskSet - a utility task set for creating tasks based on std::function.
Expand All @@ -202,8 +202,8 @@ namespace enki
{
public:
TaskSet() = default;
TaskSet( TaskSetFunction func_ ) : m_Function( func_ ) {}
TaskSet( uint32_t setSize_, TaskSetFunction func_ ) : ITaskSet( setSize_ ), m_Function( func_ ) {}
TaskSet( TaskSetFunction func_ ) : m_Function( std::move(func_) ) {}
TaskSet( uint32_t setSize_, TaskSetFunction func_ ) : ITaskSet( setSize_ ), m_Function( std::move(func_) ) {}

void ExecuteRange( TaskSetPartition range_, uint32_t threadnum_ ) override { m_Function( range_, threadnum_ ); }
TaskSetFunction m_Function;
Expand All @@ -215,8 +215,8 @@ namespace enki
{
public:
LambdaPinnedTask() = default;
LambdaPinnedTask( PinnedTaskFunction func_ ) : m_Function( func_ ) {}
LambdaPinnedTask( uint32_t threadNum_, PinnedTaskFunction func_ ) : IPinnedTask( threadNum_ ), m_Function( func_ ) {}
LambdaPinnedTask( PinnedTaskFunction func_ ) : m_Function( std::move(func_) ) {}
LambdaPinnedTask( uint32_t threadNum_, PinnedTaskFunction func_ ) : IPinnedTask( threadNum_ ), m_Function( std::move(func_) ) {}

void Execute() override { m_Function(); }
PinnedTaskFunction m_Function;
Expand Down

0 comments on commit 31dc31f

Please sign in to comment.