API Summary - ZjzMisaka/PowerThreadPool GitHub Wiki
name | summary | result |
---|---|---|
QueueWorkItem<...>(...) | Queues a work for execution. | work id |
QueueWorkItemAsync<...>(...) | Queues a async work for execution. | work id |
PauseIfRequested() | Call this function inside the work logic where you want to pause when user call Pause(...) | - |
StopIfRequested(Func beforeStop = null) | Call this function inside the work logic where you want to stop when user call Stop(...) To exit the logic, the function will throw a PowerThreadPool.Exceptions.WorkStopException. Do not catch it. If you do not want to exit the logic in this way (for example, if you have some unmanaged resources that need to be released before exiting), it is recommended to use CheckIfRequestedStop. |
- |
CheckIfRequestedStop() | Call this function inside the work logic where you want to check if requested stop (if user call Stop(...)) When returning true, you can perform some pre operations (such as releasing unmanaged resources) and then safely exit the logic. |
Requested stop or not |
Wait() | Blocks the calling thread until all of the works terminates. | - |
Wait(string id) | Blocks the calling thread until the work terminates. | Return false if the work isn't running |
Wait(IEnumerable idList) | Blocks the calling thread until the work terminates. | Return a list of ID for work that doesn't running |
WaitAsync() | Blocks the calling thread until all of the works terminates. | Task |
WaitAsync(string id) | Blocks the calling thread until the work terminates. | (Task) Return false if the work isn't running |
WaitAsync(IEnumerable idList) | Blocks the calling thread until the work terminates. | (Task) Return a list of ID for work that doesn't running |
Fetch(string id, bool removeAfterFetch = false) | Fetch the work result. | Work result |
Fetch(string id, bool removeAfterFetch = false) | Fetch the work result. | Work result |
Fetch(IEnumerable idList, bool removeAfterFetch = false) | Fetch the work result. | Work result |
Fetch(IEnumerable idList, bool removeAfterFetch = false) | Fetch the work result. | Work result |
Fetch(Func<ExecuteResult, bool> predicate, bool removeAfterFetch = false) | Fetch the work result. | Return a list of work result |
FetchAsync(string id, bool removeAfterFetch = false) | Fetch the work result. | (Task) Work result |
FetchAsync(string id, bool removeAfterFetch = false) | Fetch the work result. | (Task) Work result |
FetchAsync(IEnumerable idList, bool removeAfterFetch = false) | Fetch the work result. | (Task) Work result |
FetchAsync(IEnumerable idList, bool removeAfterFetch = false) | Fetch the work result. | (Task) Work result |
Stop(bool forceStop = false) | Stop all works. If forceStop is true, Thread.Interrupt() will be called. | Return false if no thread running |
Stop(string id, bool forceStop = false) | Stop work by id. If forceStop is true, Thread.Interrupt() will be called. | Return false if the work does not exist or has been done |
Stop(IEnumerable idList, bool forceStop = false) | Stop works by id list. If forceStop is true, Thread.Interrupt() will be called. | Return a list of ID for work that either doesn't exist or hasn't been done |
Pause() | Pause all threads | - |
Pause(string id) | Pause thread by id | If the work id exists |
Pause(IEnumerable idList) | Pause threads by id list | Return a list of IDs for work that doesn't exist |
Resume(bool resumeThreadPausedById = false) | Resume all threads | - |
Resume(string id) | Resume thread by id | If the work id exists |
Resume(IEnumerable idList) | Resume threads by id list | Return a list of IDs for work that doesn't exist |
Cancel() | Cancel all works that have not started running | - |
Cancel(string id) | Cancel the work by id if the work has not started running | is succeed |
GetGroup() | Get group object | Group object |
GetGroupMemberList() | Get all members of a group | Work id list |
AddWorkToGroup(string groupName, string workID) | Add work to group | Returns false if the work does not exist. Modifies WorkOption.Group. |
RemoveWorkFromGroup(string groupName, string workID) | Remove work from group | Returns false if either the work or the group does not exist, or if the work does not belong to the group. |
SetGroupRelation(string parentGroup, string childGroup) | Set group relation | |
RemoveGroupRelation(string parentGroup, string childGroup = null) | Remove group relation | is succeed |
ResetGroupRelation() | Reset group relation | |
For(int start, int end, Action body, int step = 1, string groupName = null) | Creates a parallel loop that executes iterations from start to end. | Group object |
For(int start, int end, IList source, Action body, int step = 1, string groupName = null) | Creates a parallel loop that executes iterations from start to end. | Group object |
For(int start, int end, IList source, Action<TSource, int> body, int step = 1, string groupName = null) | Creates a parallel loop that executes iterations from start to end. | Group object |
ForEach(IEnumerable source, Action body, string groupName = null) | Creates a parallel loop that executes a specified action for each element in the source collection. | Group object |
ForEach(IEnumerable source, Action<TSource, int> body, string groupName = null) | Creates a parallel loop that executes a specified action for each element in the source collection. | Group object |
Start() | Start the pool, but only if PowerPoolOption.StartSuspended is set to true | |
ClearResultStorage() | Clear result storage | |
ClearResultStorage(string workID) | Clear result storage | |
ClearResultStorage(IEnumerable workIDList) | Clear result storage | |
ClearFailedWorkRecord() | Clear failed work record | |
Dispose() | Will try stop, force stop and kill all of the workers. |