|
TinyLlama.cpp 1.0
A lightweight C++ implementation of the TinyLlama language model
|
Thread pool for parallel tensor loading operations. More...
#include <safetensors_loader.h>

Public Member Functions | |
| ThreadPool (size_t num_threads) | |
| Constructs a thread pool with specified number of threads. | |
| ~ThreadPool () | |
| Destructor that ensures proper cleanup of threads. | |
| template<class F , class... Args> | |
| std::future< typename std::result_of< F(Args...)>::type > | submit (F &&f, Args &&... args) |
| Submits a task to the thread pool. | |
Private Attributes | |
| std::vector< std::thread > | workers_ |
| std::queue< std::function< void()> > | tasks_ |
| std::mutex | queue_mutex_ |
| std::condition_variable | condition_ |
| bool | stop_ = false |
Thread pool for parallel tensor loading operations.
Manages a pool of worker threads for parallel processing of tensor data. Used by SafeTensorsLoader for parallel loading operations.
Definition at line 260 of file safetensors_loader.h.
|
explicit |
Constructs a thread pool with specified number of threads.
| num_threads | Number of worker threads to create |
Definition at line 684 of file safetensors_loader.cpp.
References condition_, queue_mutex_, stop_, tasks_, and workers_.
| ThreadPool::~ThreadPool | ( | ) |
Destructor that ensures proper cleanup of threads.
Definition at line 704 of file safetensors_loader.cpp.
References condition_, queue_mutex_, stop_, and workers_.
| std::future< typename std::result_of< F(Args...)>::type > ThreadPool::submit | ( | F && | f, |
| Args &&... | args | ||
| ) |
Submits a task to the thread pool.
| F | Function type |
| Args | Argument types |
| f | Function to execute |
| args | Arguments for the function |
Definition at line 294 of file safetensors_loader.h.
References condition_, queue_mutex_, stop_, and tasks_.
Referenced by SafeTensorsLoader::load_all_tensors_parallel().
|
private |
Condition variable for thread synchronization
Definition at line 288 of file safetensors_loader.h.
Referenced by submit(), ThreadPool(), and ~ThreadPool().
|
private |
Mutex for task queue access
Definition at line 287 of file safetensors_loader.h.
Referenced by submit(), ThreadPool(), and ~ThreadPool().
|
private |
Flag to stop worker threads
Definition at line 289 of file safetensors_loader.h.
Referenced by submit(), ThreadPool(), and ~ThreadPool().
|
private |
Queue of pending tasks
Definition at line 286 of file safetensors_loader.h.
Referenced by submit(), and ThreadPool().
|
private |
Worker threads
Definition at line 285 of file safetensors_loader.h.
Referenced by ThreadPool(), and ~ThreadPool().