From 544575bd09378dcf573e33a315628ecc193925e7 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 21 Sep 2019 00:04:12 +0200 Subject: Merge some of serial & pthread block processor code paths/declarations Signed-off-by: David Oberhollenzer --- lib/sqfs/blk_proc/internal.h | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'lib/sqfs/blk_proc/internal.h') diff --git a/lib/sqfs/blk_proc/internal.h b/lib/sqfs/blk_proc/internal.h index 1c33999..85c7783 100644 --- a/lib/sqfs/blk_proc/internal.h +++ b/lib/sqfs/blk_proc/internal.h @@ -9,8 +9,64 @@ #include "sqfs/error.h" #include "util.h" +#include +#include + +#ifdef WITH_PTHREAD +#include +#endif + +#ifdef WITH_PTHREAD +typedef struct { + sqfs_block_processor_t *shared; + sqfs_compressor_t *cmp; + pthread_t thread; + uint8_t scratch[]; +} compress_worker_t; +#endif + +struct sqfs_block_processor_t { + /* synchronization primitives */ +#ifdef WITH_PTHREAD + pthread_mutex_t mtx; + pthread_cond_t queue_cond; + pthread_cond_t done_cond; +#endif + + /* needs rw access by worker and main thread */ + sqfs_block_t *queue; + sqfs_block_t *queue_last; + + sqfs_block_t *done; + bool terminate; + size_t backlog; + + /* used by main thread only */ + uint32_t enqueue_id; + uint32_t dequeue_id; + + unsigned int num_workers; + sqfs_block_cb cb; + void *user; + int status; + size_t max_backlog; + + /* used only by workers */ + size_t max_block_size; + +#ifdef WITH_PTHREAD + compress_worker_t *workers[]; +#else + sqfs_compressor_t *cmp; + uint8_t scratch[]; +#endif +}; + SQFS_INTERNAL int sqfs_block_process(sqfs_block_t *block, sqfs_compressor_t *cmp, uint8_t *scratch, size_t scratch_size); +SQFS_INTERNAL int process_completed_blocks(sqfs_block_processor_t *proc, + sqfs_block_t *queue); + #endif /* INTERNAL_H */ -- cgit v1.2.3