Skip to content

Commit

Permalink
Code consistency improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dougbinks committed Mar 2, 2020
1 parent 699c343 commit c32b058
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ enki::TaskScheduler g_TS;

// define a task set, can ignore range if we only do one thing
struct ParallelTaskSet : enki::ITaskSet {
virtual void ExecuteRange( enki::TaskSetPartition range, uint32_t threadnum ) {
void ExecuteRange( enki::TaskSetPartition range_, uint32_t threadnum_ ) override {
// do something here, can issue tasks with g_TS
}
};
Expand All @@ -94,7 +94,7 @@ enki::TaskScheduler g_TS;
int main(int argc, const char * argv[]) {
g_TS.Initialize();
enki::TaskSet task( 1, []( enki::TaskSetPartition range, uint32_t threadnum ) {
enki::TaskSet task( 1, []( enki::TaskSetPartition range_, uint32_t threadnum_ ) {
// do something here
} );
Expand All @@ -117,7 +117,7 @@ struct ExampleTask : enki::ITaskSet
{
ExampleTask( ) { m_SetSize = size_; }

virtual void ExecuteRange( enki::TaskSetPartition range, uint32_t threadnum ) {
void ExecuteRange( enki::TaskSetPartition range_, uint32_t threadnum_ ) override {
// See full example in Priorities.cpp
}
};
Expand Down Expand Up @@ -161,7 +161,7 @@ enki::TaskScheduler g_TS;
// define a task set, can ignore range if we only do one thing
struct PinnedTask : enki::IPinnedTask {
virtual void Execute() {
void Execute() override {
// do something here, can issue tasks with g_TS
}
};
Expand Down Expand Up @@ -192,14 +192,14 @@ enki::TaskScheduler g_TS;

// define a task set, can ignore range if we only do one thing
struct TaskA : enki::ITaskSet {
virtual void ExecuteRange( enki::TaskSetPartition range, uint32_t threadnum ) {
void ExecuteRange( enki::TaskSetPartition range_, uint32_t threadnum_ ) override {
// do something here, can issue tasks with g_TS
}
};

struct TaskB : enki::ITaskSet {
enki::Dependency m_Dependency;
virtual void ExecuteRange( enki::TaskSetPartition range, uint32_t threadnum ) {
void ExecuteRange( enki::TaskSetPartition range_, uint32_t threadnum_ ) override {
// do something here, can issue tasks with g_TS
}
};
Expand Down Expand Up @@ -227,8 +227,7 @@ External thread usage in C++:
enki::TaskScheduler g_TS;
struct ParallelTaskSet : ITaskSet
{
virtual void ExecuteRange( TaskSetPartition range, uint32_t threadnum )
{
void ExecuteRange( enki::TaskSetPartition range_, uint32_t threadnum_ ) override {
// Do something
}
};
Expand Down Expand Up @@ -268,7 +267,7 @@ C usage:

enkiTaskScheduler* g_pTS;

void ParalleTaskSetFunc( uint32_t start_, uint32_t end, uint32_t threadnum_, void* pArgs_ ) {
void ParalleTaskSetFunc( uint32_t start_, uint32_t end_, uint32_t threadnum_, void* pArgs_ ) {
/* Do something here, can issue tasks with g_pTS */
}

Expand Down
12 changes: 6 additions & 6 deletions example/CompletionAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ struct SelfDeletingTaskB : ITaskSet
printf("~SelfDeletingTaskB() called on thread %u\n\n", g_TS.GetThreadNum() );
}

void ExecuteRange( TaskSetPartition range, uint32_t threadnum ) override
void ExecuteRange( TaskSetPartition range_, uint32_t threadnum_ ) override
{
(void)range;
(void)range_;
++gs_CountBsRun;
printf("SelfDeletingTaskB on thread %u\n", threadnum);
printf("SelfDeletingTaskB on thread %u\n", threadnum_);
}

CompletionActionDelete m_TaskDeleter;
Expand All @@ -97,11 +97,11 @@ struct SelfDeletingTaskA : ITaskSet
printf("~SelfDeletingTaskA() called on thread %u\n\n", g_TS.GetThreadNum() );
}

void ExecuteRange( TaskSetPartition range, uint32_t threadnum ) override
void ExecuteRange( TaskSetPartition range_, uint32_t threadnum_ ) override
{
(void)range;
(void)range_;
++gs_CountAsRun;
printf("SelfDeletingTaskA on thread %u\n", threadnum);
printf("SelfDeletingTaskA on thread %u\n", threadnum_);
}

CompletionActionDelete m_TaskDeleter;
Expand Down
2 changes: 1 addition & 1 deletion example/CustomAllocator_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void* CustomAllocFunc( size_t align_, size_t size_, void* userData_, const char*
return enkiDefaultAllocFunc( align_, size_, userData_, file_, line_ );
};

void CustomFreeFunc( void* ptr_, size_t size_, void* userData_, const char* file_, int line_ )
void CustomFreeFunc( void* ptr_, size_t size_, void* userData_, const char* file_, int line_ )
{
totalAllocations -= size_; // note this isn't thread safe, should use atomics in real application

Expand Down
6 changes: 3 additions & 3 deletions example/ParallelSum_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ typedef struct ParallelSumTaskSetArgs
uint32_t numPartialSums;
} ParallelSumTaskSetArgs;

void ParallelSumTaskSetFunc( uint32_t start_, uint32_t end, uint32_t threadnum_, void* pArgs_ )
void ParallelSumTaskSetFunc( uint32_t start_, uint32_t end_, uint32_t threadnum_, void* pArgs_ )
{
ParallelSumTaskSetArgs args;
uint64_t sum, i;

args = *(ParallelSumTaskSetArgs*)pArgs_;

sum = args.pPartialSums[threadnum_];
for( i = start_; i < end; ++i )
for( i = start_; i < end_; ++i )
{
sum += i + 1;
}
Expand All @@ -53,7 +53,7 @@ typedef struct ParallelReductionSumTaskSetArgs
uint64_t sum;
} ParallelReductionSumTaskSetArgs;

void ParallelReductionSumTaskSetFunc( uint32_t start_, uint32_t end, uint32_t threadnum_, void* pArgs_ )
void ParallelReductionSumTaskSetFunc( uint32_t start_, uint32_t end_, uint32_t threadnum_, void* pArgs_ )
{
ParallelReductionSumTaskSetArgs* pArgs;
uint64_t sum, i;
Expand Down
2 changes: 1 addition & 1 deletion src/TaskScheduler_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ typedef struct enkiCompletable enkiCompletable;
typedef struct enkiDependency enkiDependency;
typedef struct enkiCompletionAction enkiCompletionAction;

typedef void (* enkiTaskExecuteRange)( uint32_t start_, uint32_t end, uint32_t threadnum_, void* pArgs_ );
typedef void (* enkiTaskExecuteRange)( uint32_t start_, uint32_t end_, uint32_t threadnum_, void* pArgs_ );
typedef void (* enkiPinnedTaskExecute)( void* pArgs_ );
typedef void (* enkiCompletionFunction)( void* pArgs_, uint32_t threadNum_ );

Expand Down

0 comments on commit c32b058

Please sign in to comment.