Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Restructure dirs#181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
deanberris merged 5 commits intocpp-netlib:masterfromglynos:restructure_dirs
Jan 2, 2013
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Refactored thread_pool from the utils sub-directory (and namespace) i…
…nto concurrency.
  • Loading branch information
@glynos
glynos committedDec 29, 2012
commitc246806d1c3eb563d2dff81f1ec5cbb0c7dee066
1 change: 1 addition & 0 deletionsCMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,3 +113,4 @@ message(STATUS " CPP-NETLIB_DISABLE_LOGGING: ${CPP-NETLIB_DISABLE_LOGGING}\t(
add_subdirectory(uri)
add_subdirectory(message)
add_subdirectory(logging)
add_subdirectory(concurrency)
11 changes: 11 additions & 0 deletionsconcurrency/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
# Copyright (c) Glyn Matthews 2012.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

add_subdirectory(src)

if(CPP-NETLIB_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif(CPP-NETLIB_BUILD_TESTS)
30 changes: 30 additions & 0 deletionsconcurrency/src/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
# Copyright (c) Glyn Matthews 2012.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

include_directories(${CPP-NETLIB_SOURCE_DIR}/concurrency/src)

if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
if (HAVE_STD11)
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
elseif (HAVE_STD0X)
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++0x")
endif()
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
endif()

set(CPP-NETLIB_CONCURRENCY_SRCS thread_pool.cpp)
add_library(cppnetlib-concurrency ${CPP-NETLIB_CONCURRENCY_SRCS})
foreach (src_file ${CPP-NETLIB_CONCURRENCY_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
set_source_files_properties(${src_file}
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
endif()
endforeach(src_file)
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
// Copyright 2010 Dean Michael Berris.
// Copyright 2012 Google, Inc.
// Copyright (c) Glyn Matthews 2012.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndefNETWORK_UTILS_THREAD_POOL_HPP_20101020
#defineNETWORK_UTILS_THREAD_POOL_HPP_20101020
#ifndefNETWORK_CONCURRENCY_THREAD_POOL_HPP_20101020
#defineNETWORK_CONCURRENCY_THREAD_POOL_HPP_20101020

#include <cstddef>
#include <thread>
Expand All@@ -14,7 +15,7 @@
#include <vector>
#include <boost/asio/io_service.hpp>

namespace network { namespaceutils {
namespace network { namespaceconcurrency {

typedef std::shared_ptr<boost::asio::io_service> io_service_ptr;
typedef std::shared_ptr<std::vector<std::thread>> worker_threads_ptr;
Expand DownExpand Up@@ -46,7 +47,7 @@ namespace network { namespace utils {
l.swap(r);
}

} // namespaceutils
} // namespaceconcurrency
} // namespace network

#endif /*NETWORK_UTILS_THREAD_POOL_HPP_20101020 */
#endif /*NETWORK_CONCURRENCY_THREAD_POOL_HPP_20101020 */
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
// Copyright 2011 Google, Inc.
// Copyright (c) Glyn Matthews 2012.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndefNETWORK_UTILS_THREAD_POOL_IPP_20111021
#defineNETWORK_UTILS_THREAD_POOL_IPP_20111021
#ifndefNETWORK_CONCURRENCY_THREAD_POOL_IPP_20111021
#defineNETWORK_CONCURRENCY_THREAD_POOL_IPP_20111021

#include <vector>
#include <thread>
#include <network/utils/thread_pool.hpp>
#include <network/concurrency/thread_pool.hpp>
#include <boost/scope_exit.hpp>

namespace network { namespaceutils {
namespace network { namespaceconcurrency {

struct thread_pool_pimpl {
thread_pool_pimpl(std::size_t threads = 1,
Expand DownExpand Up@@ -109,7 +110,7 @@ namespace network { namespace utils {
delete pimpl;
}

} // namespaceutils
} // namespaceconcurrency
} // namespace network

#endif /*NETWORK_UTILS_THREAD_POOL_IPP_20111021 */
#endif /*NETWORK_CONCURRENCY_THREAD_POOL_IPP_20111021 */
19 changes: 19 additions & 0 deletionsconcurrency/src/network/utils/thread_pool.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
// Copyright (c) Glyn Matthews 2012.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)


#ifndef __NETWORK_UTILS_THREAD_POOL_INC__
#define __NETWORK_UTILS_THREAD_POOL_INC__

#include <network/concurrency/thread_pool.hpp>

namespace network {
namespace utils {
typedef ::network::concurrency::thread_pool thread_pool;
} // namespace utils
} // namespace network


#endif // __NETWORK_UTILS_THREAD_POOL_INC__
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
// Copyright 2011 Google, Inc.
// Copyright (c) Glyn Matthews 2012.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <network/utils/thread_pool.ipp>
#include <network/concurrency/thread_pool.ipp>
29 changes: 29 additions & 0 deletionsconcurrency/test/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
# Copyright (c) Glyn Matthews 2012.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

include_directories(${CPP-NETLIB_SOURCE_DIR}/concurrency/src)

if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
if (HAVE_STD11)
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
elseif (HAVE_STD0X)
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++0x")
endif()
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
endif()

set_source_files_properties(thread_pool_test.cpp
PROPERTIES COMPILE_FLAGS "-Wall")
add_executable(cpp-netlib-thread_pool_test thread_pool_test.cpp)
target_link_libraries(cpp-netlib-thread_pool_test
cppnetlib-concurrency
${Boost_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
set_target_properties(cpp-netlib-thread_pool_test
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
add_test(cpp-netlib-thread_pool_test ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-thread_pool_test)
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@

// Copyright 2010 Dean Michael Berris.
// Copyright 2012 Google, Inc.
// Copyright (c) Glyn Matthews 2012.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifdef BUILD_SHARED_LIBS
# define BOOST_TEST_DYN_LINK
#endif
#define BOOST_TEST_MODULEutilsthread pool test
#define BOOST_TEST_MODULE thread pool test
#include <boost/config/warning_disable.hpp>
#include <boost/test/unit_test.hpp>
#include <network/utils/thread_pool.hpp>
#include <network/concurrency/thread_pool.hpp>
#include <boost/bind.hpp>

usingnamespacenetwork;
using network::concurrency::thread_pool;

// This test specifies the requirements for a thread pool interface. At the
// very least any thread pool implementation should be able to pass the simple
Expand All@@ -25,29 +26,29 @@ using namespace network;
//

BOOST_AUTO_TEST_CASE( default_constructor ) {
utils::thread_pool pool;
BOOST_CHECK_EQUAL(pool.thread_count(), std::size_t(1));
thread_pool pool;
BOOST_CHECK_EQUAL(pool.thread_count(), std::size_t(1));
}

struct foo {
foo() : val_(0) {}
void bar(int val) {
val_ += val;
}
int const val() const {
return val_;
}
foo() : val_(0) {}
void bar(int val) {
val_ += val;
}
int const val() const {
return val_;
}
protected:
int val_;
int val_;
};

BOOST_AUTO_TEST_CASE( post_work ) {
foo instance;
{
utils::thread_pool pool;
BOOST_CHECK_NO_THROW(pool.post(boost::bind(&foo::bar, &instance, 1)));
BOOST_CHECK_NO_THROW(pool.post(boost::bind(&foo::bar, &instance, 2)));
// require that pool is destroyed here, RAII baby
}
BOOST_CHECK_EQUAL(instance.val(), 3);
foo instance;
{
thread_pool pool;
BOOST_CHECK_NO_THROW(pool.post(boost::bind(&foo::bar, &instance, 1)));
BOOST_CHECK_NO_THROW(pool.post(boost::bind(&foo::bar, &instance, 2)));
// require that pool is destroyed here, RAII baby
}
BOOST_CHECK_EQUAL(instance.val(), 3);
}
12 changes: 0 additions & 12 deletionslibs/network/src/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -172,18 +172,6 @@ elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
endif()
endforeach(src_file)

set(CPP-NETLIB_UTILS_THREAD_POOL_SRCS utils/thread_pool.cpp)
add_library(cppnetlib-utils-thread_pool ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS})
foreach (src_file ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set_source_files_properties(${src_file}
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
set_source_files_properties(${src_file}
PROPERTIES COMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
endif()
endforeach(src_file)

set(CPP-NETLIB_CONSTANTS_SRCS constants.cpp)
add_library(cppnetlib-constants ${CPP-NETLIB_CONSTANTS_SRCS})
foreach (src_file ${CPP-NETLIB_CONSTANTS_SRCS})
Expand Down
16 changes: 0 additions & 16 deletionslibs/network/test/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,19 +10,3 @@ if(CPP-NETLIB_BUILD_SHARED_LIBS)
endif()

add_subdirectory(http)

if (Boost_FOUND)

set_source_files_properties(utils_thread_pool.cpp
PROPERTIES COMPILE_FLAGS "-Wall")
add_executable(cpp-netlib-utils_thread_pool utils_thread_pool.cpp)
target_link_libraries(cpp-netlib-utils_thread_pool
cppnetlib-utils-thread_pool
${Boost_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
set_target_properties(cpp-netlib-utils_thread_pool
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
add_test(cpp-netlib-utils_thread_pool ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-utils_thread_pool)

endif()


[8]ページ先頭

©2009-2025 Movatter.jp