Shaka Packager SDK
Loading...
Searching...
No Matches
packager
file
thread_pool.h
1
// Copyright 2022 Google LLC. All rights reserved.
2
//
3
// Use of this source code is governed by a BSD-style
4
// license that can be found in the LICENSE file or at
5
// https://developers.google.com/open-source/licenses/bsd
6
7
#ifndef PACKAGER_FILE_THREAD_POOL_H_
8
#define PACKAGER_FILE_THREAD_POOL_H_
9
10
#include <cstddef>
11
#include <functional>
12
#include <queue>
13
14
#include <absl/base/thread_annotations.h>
15
#include <absl/synchronization/mutex.h>
16
17
#include <packager/macros/classes.h>
18
19
namespace
shaka
{
20
25
class
ThreadPool
{
26
public
:
27
typedef
std::function<void()> Task;
28
29
ThreadPool
();
30
~ThreadPool
();
31
34
void
PostTask
(
const
Task& task);
35
36
static
ThreadPool
instance;
37
38
private
:
41
void
Terminate();
42
43
Task WaitForTask();
44
void
ThreadMain();
45
46
absl::Mutex mutex_;
47
absl::CondVar tasks_available_ ABSL_GUARDED_BY(mutex_);
48
std::queue<Task> tasks_ ABSL_GUARDED_BY(mutex_);
49
size_t
num_idle_threads_ ABSL_GUARDED_BY(mutex_);
50
bool
terminated_ ABSL_GUARDED_BY(mutex_);
51
52
DISALLOW_COPY_AND_ASSIGN(
ThreadPool
);
53
};
54
55
}
// namespace shaka
56
57
#endif
// PACKAGER_FILE_THREAD_POOL_H_
shaka::ThreadPool
Definition
thread_pool.h:25
shaka::ThreadPool::PostTask
void PostTask(const Task &task)
Definition
thread_pool.cc:35
shaka
All the methods that are virtual are virtual for mocking.
Definition
cpix_encryption_flags.cc:51
Generated on Mon Jul 27 2026 18:29:59 for Shaka Packager SDK by
1.9.8