Browse Source
Allow building Tenacity without Conan
Allow building Tenacity without Conan
Conan can still be used, but it is fully optional. This should help packagers a lot. Signed-off-by: Edgar <Edgar@AnotherFoxGuy.com>pull/418/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 276 additions and 1313 deletions
-
8CMakeLists.txt
-
16cmake-proxies/CMakeLists.txt
-
60cmake-proxies/cmake-modules/AudacityDependencies.cmake
-
76cmake-proxies/cmake-modules/Findlibmp3lame.cmake
-
1290cmake-proxies/cmake-modules/FindwxWidgets.cmake
-
2cmake-proxies/cmake-modules/dependencies/wxwidgets.cmake
-
2help/CMakeLists.txt
-
20lib-src/ThreadPool/COPYING
-
17lib-src/ThreadPool/README.md
-
98lib-src/ThreadPool/ThreadPool.h
@ -0,0 +1,76 @@ |
|||
# This file is part of Mixxx, Digital DJ'ing software. |
|||
# Copyright (C) 2001-2020 Mixxx Development Team |
|||
# Distributed under the GNU General Public Licence (GPL) version 2 or any later |
|||
# later version. See the LICENSE file for details. |
|||
|
|||
#[=======================================================================[.rst: |
|||
Findlibmp3lame |
|||
----------- |
|||
|
|||
Finds the LAME library. |
|||
|
|||
Imported Targets |
|||
^^^^^^^^^^^^^^^^ |
|||
|
|||
This module provides the following imported targets, if found: |
|||
|
|||
``libmp3lame::libmp3lame`` |
|||
The LAME library |
|||
|
|||
Result Variables |
|||
^^^^^^^^^^^^^^^^ |
|||
|
|||
This will define the following variables: |
|||
|
|||
``libmp3lame_FOUND`` |
|||
True if the system has the LAME library. |
|||
``libmp3lame_INCLUDE_DIRS`` |
|||
Include directories needed to use LAME. |
|||
``libmp3lame_LIBRARIES`` |
|||
Libraries needed to link to LAME. |
|||
|
|||
Cache Variables |
|||
^^^^^^^^^^^^^^^ |
|||
|
|||
The following cache variables may also be set: |
|||
|
|||
``libmp3lame_INCLUDE_DIR`` |
|||
The directory containing ``lame/lame.h``. |
|||
``libmp3lame_LIBRARY`` |
|||
The path to the LAME library. |
|||
|
|||
#]=======================================================================] |
|||
|
|||
find_path(libmp3lame_INCLUDE_DIR |
|||
NAMES lame/lame.h |
|||
DOC "LAME include directory") |
|||
mark_as_advanced(libmp3lame_INCLUDE_DIR) |
|||
|
|||
find_library(libmp3lame_LIBRARY |
|||
NAMES mp3lame mp3lame-static |
|||
DOC "LAME library" |
|||
) |
|||
mark_as_advanced(libmp3lame_LIBRARY) |
|||
|
|||
include(FindPackageHandleStandardArgs) |
|||
find_package_handle_standard_args( |
|||
libmp3lame |
|||
DEFAULT_MSG |
|||
libmp3lame_LIBRARY |
|||
libmp3lame_INCLUDE_DIR |
|||
) |
|||
|
|||
if(libmp3lame_FOUND) |
|||
set(libmp3lame_LIBRARIES "${libmp3lame_LIBRARY}") |
|||
set(libmp3lame_INCLUDE_DIRS "${libmp3lame_INCLUDE_DIR}") |
|||
|
|||
if(NOT TARGET libmp3lame::libmp3lame) |
|||
add_library(libmp3lame::libmp3lame INTERFACE IMPORTED GLOBAL) |
|||
set_target_properties(libmp3lame::libmp3lame |
|||
PROPERTIES |
|||
INTERFACE_LINK_LIBRARIES "${libmp3lame_LIBRARIES}" |
|||
INTERFACE_INCLUDE_DIRECTORIES "${libmp3lame_INCLUDE_DIRS}" |
|||
) |
|||
endif() |
|||
message("Found libmp3lame: ${libmp3lame_INCLUDE_DIRS} | ${libmp3lame_LIBRARIES}") |
|||
endif() |
1290
cmake-proxies/cmake-modules/FindwxWidgets.cmake
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,20 @@ |
|||
Copyright (c) 2012 Jakob Progsch, Václav Zeman |
|||
|
|||
This software is provided 'as-is', without any express or implied |
|||
warranty. In no event will the authors be held liable for any damages |
|||
arising from the use of this software. |
|||
|
|||
Permission is granted to anyone to use this software for any purpose, |
|||
including commercial applications, and to alter it and redistribute it |
|||
freely, subject to the following restrictions: |
|||
|
|||
1. The origin of this software must not be misrepresented; you must not |
|||
claim that you wrote the original software. If you use this software |
|||
in a product, an acknowledgment in the product documentation would be |
|||
appreciated but is not required. |
|||
|
|||
2. Altered source versions must be plainly marked as such, and must not be |
|||
misrepresented as being the original software. |
|||
|
|||
3. This notice may not be removed or altered from any source |
|||
distribution. |
@ -0,0 +1,17 @@ |
|||
ThreadPool |
|||
========== |
|||
|
|||
A simple C++11 Thread Pool implementation. |
|||
|
|||
Basic usage: |
|||
```c++ |
|||
// create thread pool with 4 worker threads |
|||
ThreadPool pool(4); |
|||
|
|||
// enqueue and store future |
|||
auto result = pool.enqueue([](int answer) { return answer; }, 42); |
|||
|
|||
// get result from future |
|||
std::cout << result.get() << std::endl; |
|||
|
|||
``` |
@ -0,0 +1,98 @@ |
|||
#ifndef THREAD_POOL_H |
|||
#define THREAD_POOL_H |
|||
|
|||
#include <vector> |
|||
#include <queue> |
|||
#include <memory> |
|||
#include <thread> |
|||
#include <mutex> |
|||
#include <condition_variable> |
|||
#include <future> |
|||
#include <functional> |
|||
#include <stdexcept> |
|||
|
|||
class ThreadPool { |
|||
public: |
|||
ThreadPool(size_t); |
|||
template<class F, class... Args> |
|||
auto enqueue(F&& f, Args&&... args) |
|||
-> std::future<typename std::result_of<F(Args...)>::type>; |
|||
~ThreadPool(); |
|||
private: |
|||
// need to keep track of threads so we can join them |
|||
std::vector< std::thread > workers; |
|||
// the task queue |
|||
std::queue< std::function<void()> > tasks; |
|||
|
|||
// synchronization |
|||
std::mutex queue_mutex; |
|||
std::condition_variable condition; |
|||
bool stop; |
|||
}; |
|||
|
|||
// the constructor just launches some amount of workers |
|||
inline ThreadPool::ThreadPool(size_t threads) |
|||
: stop(false) |
|||
{ |
|||
for(size_t i = 0;i<threads;++i) |
|||
workers.emplace_back( |
|||
[this] |
|||
{ |
|||
for(;;) |
|||
{ |
|||
std::function<void()> task; |
|||
|
|||
{ |
|||
std::unique_lock<std::mutex> lock(this->queue_mutex); |
|||
this->condition.wait(lock, |
|||
[this]{ return this->stop || !this->tasks.empty(); }); |
|||
if(this->stop && this->tasks.empty()) |
|||
return; |
|||
task = std::move(this->tasks.front()); |
|||
this->tasks.pop(); |
|||
} |
|||
|
|||
task(); |
|||
} |
|||
} |
|||
); |
|||
} |
|||
|
|||
// add new work item to the pool |
|||
template<class F, class... Args> |
|||
auto ThreadPool::enqueue(F&& f, Args&&... args) |
|||
-> std::future<typename std::result_of<F(Args...)>::type> |
|||
{ |
|||
using return_type = typename std::result_of<F(Args...)>::type; |
|||
|
|||
auto task = std::make_shared< std::packaged_task<return_type()> >( |
|||
std::bind(std::forward<F>(f), std::forward<Args>(args)...) |
|||
); |
|||
|
|||
std::future<return_type> res = task->get_future(); |
|||
{ |
|||
std::unique_lock<std::mutex> lock(queue_mutex); |
|||
|
|||
// don't allow enqueueing after stopping the pool |
|||
if(stop) |
|||
throw std::runtime_error("enqueue on stopped ThreadPool"); |
|||
|
|||
tasks.emplace([task](){ (*task)(); }); |
|||
} |
|||
condition.notify_one(); |
|||
return res; |
|||
} |
|||
|
|||
// the destructor joins all threads |
|||
inline ThreadPool::~ThreadPool() |
|||
{ |
|||
{ |
|||
std::unique_lock<std::mutex> lock(queue_mutex); |
|||
stop = true; |
|||
} |
|||
condition.notify_all(); |
|||
for(std::thread &worker: workers) |
|||
worker.join(); |
|||
} |
|||
|
|||
#endif |
Write
Preview
Loading…
Cancel
Save
Reference in new issue