parent
8bea9f4455
commit
762eb9ca33
|
|
@ -167,7 +167,10 @@ endif (USE_AMR_CODEC)
|
||||||
target_link_libraries(rtphone
|
target_link_libraries(rtphone
|
||||||
ice_stack jrtplib g729_codec gsm_codec
|
ice_stack jrtplib g729_codec gsm_codec
|
||||||
gsmhr_codec g722_codec srtp resiprocate
|
gsmhr_codec g722_codec srtp resiprocate
|
||||||
helper_lib audio_lib webrtc speexdsp
|
helper_lib
|
||||||
|
audio_lib
|
||||||
|
webrtc
|
||||||
|
speexdsp
|
||||||
opus
|
opus
|
||||||
uuid
|
uuid
|
||||||
${OPENSSL_SSL}
|
${OPENSSL_SSL}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,11 @@ long SyncHelper::increment(long *value)
|
||||||
void ThreadHelper::setName(const std::string &name)
|
void ThreadHelper::setName(const std::string &name)
|
||||||
{
|
{
|
||||||
#if defined(TARGET_LINUX)
|
#if defined(TARGET_LINUX)
|
||||||
pthread_setname_np(pthread_self(), name.c_str());
|
int retcode = pthread_setname_np(pthread_self(), name.c_str());
|
||||||
|
if (retcode != 0)
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to set Linux thread name" << std::endl;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,12 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include "HL_Sync.h"
|
||||||
|
|
||||||
class ThreadPool
|
class ThreadPool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ThreadPool(size_t);
|
ThreadPool(size_t, const std::string&);
|
||||||
template<class F, class... Args>
|
template<class F, class... Args>
|
||||||
auto enqueue(F&& f, Args&&... args)
|
auto enqueue(F&& f, Args&&... args)
|
||||||
-> std::future<typename std::result_of<F(Args...)>::type>;
|
-> std::future<typename std::result_of<F(Args...)>::type>;
|
||||||
|
|
@ -31,16 +32,18 @@ private:
|
||||||
std::mutex queue_mutex;
|
std::mutex queue_mutex;
|
||||||
std::condition_variable condition;
|
std::condition_variable condition;
|
||||||
bool stop, pause;
|
bool stop, pause;
|
||||||
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
// the constructor just launches some amount of workers
|
// the constructor just launches some amount of workers
|
||||||
inline ThreadPool::ThreadPool(size_t threads)
|
inline ThreadPool::ThreadPool(size_t threads, const std::string& name)
|
||||||
: stop(false), pause(false)
|
: stop(false), pause(false), name(name)
|
||||||
{
|
{
|
||||||
for(size_t i = 0;i<threads;++i)
|
for(size_t i = 0;i<threads;++i)
|
||||||
workers.emplace_back(
|
workers.emplace_back(
|
||||||
[this]
|
[this, i]
|
||||||
{
|
{
|
||||||
|
ThreadHelper::setName(this->name + std::to_string(i));
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
std::function<void()> task; bool task_assigned = false;
|
std::function<void()> task; bool task_assigned = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue