diff options
| author | Dan Engelbrecht <[email protected]> | 2025-06-05 14:40:02 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-06-05 14:40:02 +0200 |
| commit | 40b9386054de3c23f77da74eefaa743240d164fd (patch) | |
| tree | 9c4448f86d1df00b3d0f5d5dd94506bca8c067d9 /src/zenutil/include | |
| parent | revert system temp dir for builds upload (#422) (diff) | |
| download | zen-40b9386054de3c23f77da74eefaa743240d164fd.tar.xz zen-40b9386054de3c23f77da74eefaa743240d164fd.zip | |
pause, resume and abort running builds cmd (#421)
- Feature: `zen builds pause`, `zen builds resume` and `zen builds abort` commands to control a running `zen builds` command
- `--process-id` the process id to control, if omitted it tries to find a running process using the same executable as itself
- Improvement: Process report now indicates if it is pausing or aborting
Diffstat (limited to 'src/zenutil/include')
| -rw-r--r-- | src/zenutil/include/zenutil/chunkedcontent.h | 17 | ||||
| -rw-r--r-- | src/zenutil/include/zenutil/parallelwork.h | 13 |
2 files changed, 18 insertions, 12 deletions
diff --git a/src/zenutil/include/zenutil/chunkedcontent.h b/src/zenutil/include/zenutil/chunkedcontent.h index 225b1a3a5..306a5d990 100644 --- a/src/zenutil/include/zenutil/chunkedcontent.h +++ b/src/zenutil/include/zenutil/chunkedcontent.h @@ -132,14 +132,15 @@ struct ChunkingStatistics uint64_t ElapsedWallTimeUS = 0; }; -ChunkedFolderContent ChunkFolderContent(ChunkingStatistics& Stats, - WorkerThreadPool& WorkerPool, - const std::filesystem::path& RootPath, - const FolderContent& Content, - const ChunkingController& InChunkingController, - int32_t UpdateIntervalMS, - std::function<void(bool IsAborted, std::ptrdiff_t PendingWork)>&& UpdateCallback, - std::atomic<bool>& AbortFlag); +ChunkedFolderContent ChunkFolderContent(ChunkingStatistics& Stats, + WorkerThreadPool& WorkerPool, + const std::filesystem::path& RootPath, + const FolderContent& Content, + const ChunkingController& InChunkingController, + int32_t UpdateIntervalMS, + std::function<void(bool IsAborted, bool IsPaused, std::ptrdiff_t PendingWork)>&& UpdateCallback, + std::atomic<bool>& AbortFlag, + std::atomic<bool>& PauseFlag); ChunkedContentLookup BuildChunkedContentLookup(const ChunkedFolderContent& Content); diff --git a/src/zenutil/include/zenutil/parallelwork.h b/src/zenutil/include/zenutil/parallelwork.h index 08e730b28..d7e986551 100644 --- a/src/zenutil/include/zenutil/parallelwork.h +++ b/src/zenutil/include/zenutil/parallelwork.h @@ -12,13 +12,13 @@ namespace zen { class ParallelWork { public: - ParallelWork(std::atomic<bool>& AbortFlag); + ParallelWork(std::atomic<bool>& AbortFlag, std::atomic<bool>& PauseFlag); ~ParallelWork(); - typedef std::function<void(std::atomic<bool>& AbortFlag)> WorkCallback; - typedef std::function<void(std::exception_ptr Ex, std::atomic<bool>& AbortFlag)> ExceptionCallback; - typedef std::function<void(bool IsAborted, std::ptrdiff_t PendingWork)> UpdateCallback; + typedef std::function<void(std::atomic<bool>& AbortFlag)> WorkCallback; + typedef std::function<void(std::exception_ptr Ex, std::atomic<bool>& AbortFlag)> ExceptionCallback; + typedef std::function<void(bool IsAborted, bool IsPaused, std::ptrdiff_t PendingWork)> UpdateCallback; void ScheduleWork(WorkerThreadPool& WorkerPool, WorkCallback&& Work, ExceptionCallback&& OnError = {}) { @@ -28,6 +28,10 @@ public: WorkerPool.ScheduleWork([this, Work = std::move(Work), OnError = OnError ? std::move(OnError) : DefaultErrorFunction()] { try { + while (m_PauseFlag && !m_AbortFlag) + { + Sleep(2000); + } Work(m_AbortFlag); } catch (...) @@ -59,6 +63,7 @@ private: void RethrowErrors(); std::atomic<bool>& m_AbortFlag; + std::atomic<bool>& m_PauseFlag; bool m_DispatchComplete = false; Latch m_PendingWork; |