-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1a147a
commit 335cec5
Showing
7 changed files
with
134 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include "../types.hpp" | ||
#include "../core/threadManager.hpp" | ||
|
||
namespace ammonite { | ||
namespace utils { | ||
namespace thread { | ||
unsigned int getThreadPoolSize() { | ||
return ammonite::thread::internal::getThreadPoolSize(); | ||
} | ||
|
||
void submitWork(AmmoniteWork work, void* userPtr) { | ||
ammonite::thread::internal::submitWork(work, userPtr, nullptr); | ||
} | ||
|
||
void submitWork(AmmoniteWork work, void* userPtr, AmmoniteCompletion* completion) { | ||
ammonite::thread::internal::submitWork(work, userPtr, completion); | ||
} | ||
|
||
//userBuffer and completions may be null | ||
void submitMultiple(AmmoniteWork work, void* userBuffer, int stride, | ||
AmmoniteCompletion* completions, unsigned int jobCount) { | ||
ammonite::thread::internal::submitMultiple(work, userBuffer, stride, completions, jobCount); | ||
} | ||
|
||
//Wait for completion to be finished | ||
void waitWorkComplete(AmmoniteCompletion* completion) { | ||
//Wait for completion to become true | ||
if (completion != nullptr) { | ||
completion->wait(false); | ||
} | ||
} | ||
|
||
//Wait for completion to be finished, without a nullptr check | ||
void waitWorkCompleteUnsafe(AmmoniteCompletion* completion) { | ||
//Wait for completion to become true | ||
completion->wait(false); | ||
} | ||
|
||
//Reset completion to be used again | ||
void resetCompletion(AmmoniteCompletion* completion) { | ||
//Reset the completion to false | ||
if (completion != nullptr) { | ||
completion->clear(); | ||
} | ||
} | ||
|
||
//Reset completion to be used again, without a nullptr check | ||
void resetCompletionUnsafe(AmmoniteCompletion* completion) { | ||
//Reset the completion to false | ||
completion->clear(); | ||
} | ||
|
||
void blockThreadsAsync() { | ||
ammonite::thread::internal::blockThreads(false); | ||
} | ||
|
||
void blockThreadsSync() { | ||
ammonite::thread::internal::blockThreads(true); | ||
} | ||
|
||
void unblockThreadsAsync() { | ||
ammonite::thread::internal::unblockThreads(false); | ||
} | ||
|
||
void unblockThreadsSync() { | ||
ammonite::thread::internal::unblockThreads(true); | ||
} | ||
|
||
void finishWork() { | ||
ammonite::thread::internal::finishWork(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef THREAD | ||
#define THREAD | ||
|
||
#include "../types.hpp" | ||
|
||
namespace ammonite { | ||
namespace utils { | ||
namespace thread { | ||
unsigned int getThreadPoolSize(); | ||
void submitWork(AmmoniteWork work, void* userPtr); | ||
void submitWork(AmmoniteWork work, void* userPtr, AmmoniteCompletion* completion); | ||
void submitMultiple(AmmoniteWork work, void* userBuffer, int stride, | ||
AmmoniteCompletion* completions, unsigned int jobCount); | ||
void waitWorkComplete(AmmoniteCompletion* completion); | ||
void waitWorkCompleteUnsafe(AmmoniteCompletion* completion); | ||
void resetCompletion(AmmoniteCompletion* completion); | ||
void resetCompletionUnsafe(AmmoniteCompletion* completion); | ||
|
||
void blockThreadsAsync(); | ||
void blockThreadsSync(); | ||
void unblockThreadsSync(); | ||
void unblockThreadsAsync(); | ||
void finishWork(); | ||
} | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.