Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "stdafx.h"

#include "Headers/ThreadPool.h"

namespace Divide {

// --------------------------- POOL TASK -------------------------------//
PoolTask::PoolTask(std::function<void()> task)
    : PoolTask(0, task)
{
}

PoolTask::PoolTask(I32 priority, std::function<void()> task)
    : _priority(priority),
    _task(task)
{
}

void PoolTask::operator()() {
    if (_task) {
        _task();
    }
}

// --------------------------- THREAD POOL -------------------------------//
ThreadPool::ThreadPool(I32 numThreads)
    : _numThreads(numThreads)
{
}

ThreadPool::~ThreadPool()
{
}

I32 ThreadPool::numThreads() const {
    return _numThreads;
}


// --------------------------- THREAD POOL C++11-------------------------------//
ThreadPoolC11::ThreadPoolC11(I32 numThreads)
    : ThreadPool(numThreads),
      _pool(numThreads)
{

}

ThreadPoolC11::~ThreadPoolC11()
{
    stopAll();
    waitAll();
}

bool ThreadPoolC11::enqueue(const PoolTask& task) {
    _pool.push([task](size_t id) { task._task(); });
    return true;
}

void ThreadPoolC11::stopAll() {
    _pool.clear_queue();
}

void ThreadPoolC11::waitAll() {
    while (_pool.n_idle() != _pool.size()) {
        std::this_thread::yield();
    }
}

// --------------------------- THREAD POOL Boost Prio-------------------------------//
ThreadPoolBoostPrio::ThreadPoolBoostPrio(I32 numThreads)
    : ThreadPool(numThreads),
      _pool(numThreads)
{

}

ThreadPoolBoostPrio::~ThreadPoolBoostPrio()
{
    stopAll();
    waitAll();
}

bool ThreadPoolBoostPrio::enqueue(const PoolTask& task) {
    return _pool.schedule(boost::threadpool::prio_task_func(task._priority, task._task));
}

void ThreadPoolBoostPrio::stopAll() {
    _pool.clear();
}

void ThreadPoolBoostPrio::waitAll() {
    _pool.wait();
}


// --------------------------- THREAD POOL Boost FIFO-------------------------------//
ThreadPoolBoostFifo::ThreadPoolBoostFifo(I32 numThreads)
    : ThreadPool(numThreads),
    _pool(numThreads)
{

}

ThreadPoolBoostFifo::~ThreadPoolBoostFifo()
{
    stopAll();
    waitAll();
}

bool ThreadPoolBoostFifo::enqueue(const PoolTask& task) {
    return _pool.schedule(boost::threadpool::task_func(task._task));
}

void ThreadPoolBoostFifo::stopAll() {
    _pool.clear();
}

void ThreadPoolBoostFifo::waitAll() {
    _pool.wait();
}
}; //namespace Divide

Commits for Divide-Framework/trunk/Source Code/Platform/Threading/ThreadPoolImpl.cpp

Diff revisions: vs.
Revision Author Commited Message
1012 Diff Diff IonutCava picture IonutCava Mon 15 Jan, 2018 17:21:32 +0000

[Ionut]
- Update boost to v1.66
- Performance optimizations

943 Diff Diff IonutCava picture IonutCava Tue 12 Sep, 2017 11:38:52 +0000

[IonutCava]
- Rework ThreadPool/Task system for clearer parent<->child relationship between tasks
— Disable Prio pool since it doesn’t work properly with the newest boost libraries
— Modify the C++11 threadpool to remove the boost dependency
- Reduce memory usage by allocating command buffers on use instead of on creation

895 Diff Diff IonutCava picture IonutCava Wed 21 Jun, 2017 21:10:26 +0000

[IonutCava]
- Reorder and cleanup OpenGL backend a bit.
- Small code cleanup
- Some small profile-guided optimizations

890 Diff Diff IonutCava picture IonutCava Sun 14 May, 2017 20:54:59 +0000

[Ionut]
- Add pre-compiled header support
- Initial code for per-stage tessellation computation

873 IonutCava picture IonutCava Thu 09 Mar, 2017 16:11:50 +0000

[IonutCava]
- Add support for swapping threadpool implementations
- Add 3 threadpool implementations: boost priority pool, boost fifo pool and CTPL (https://github.com/vit-vit/CTPL)