Commit 6804da2f authored by Joseph Noir's avatar Joseph Noir

Merge branch 'unstable' of github.com:Neverlord/libcppa into unstable

parents 81552795 3ed767b6
...@@ -26,7 +26,7 @@ else (CMAKE_CXX_FLAGS) ...@@ -26,7 +26,7 @@ else (CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "-std=c++11 -Wextra -Wall -pedantic") set(CMAKE_CXX_FLAGS "-std=c++11 -Wextra -Wall -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os") set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
endif (CMAKE_CXX_FLAGS) endif (CMAKE_CXX_FLAGS)
...@@ -72,11 +72,11 @@ endif () ...@@ -72,11 +72,11 @@ endif ()
# set build type (evaluate ENABLE_DEBUG flag) # set build type (evaluate ENABLE_DEBUG flag)
if (ENABLE_DEBUG) if (ENABLE_DEBUG)
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_DEBUG_MODE") add_definitions(-DCPPA_DEBUG_MODE)
endif (ENABLE_DEBUG) endif (ENABLE_DEBUG)
if (CPPA_LOG_LEVEL) if (CPPA_LOG_LEVEL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_LOG_LEVEL=${CPPA_LOG_LEVEL}") add_definitions(-DCPPA_LOG_LEVEL=${CPPA_LOG_LEVEL})
endif(CPPA_LOG_LEVEL) endif(CPPA_LOG_LEVEL)
# set build default build type if not set # set build default build type if not set
...@@ -185,9 +185,13 @@ if (ENABLE_OPENCL) ...@@ -185,9 +185,13 @@ if (ENABLE_OPENCL)
src/opencl/program.cpp src/opencl/program.cpp
src/opencl/actor_facade.cpp src/opencl/actor_facade.cpp
src/opencl/command_dispatcher.cpp) src/opencl/command_dispatcher.cpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_OPENCL") add_definitions(-DCPPA_OPENCL)
endif (ENABLE_OPENCL) endif (ENABLE_OPENCL)
if (DISABLE_MEM_MANAGEMENT)
add_definitions(-DCPPA_DISABLE_MEM_MANAGEMENT)
endif (DISABLE_MEM_MANAGEMENT)
if (DISABLE_CONTEXT_SWITCHING) if (DISABLE_CONTEXT_SWITCHING)
# explicitly disabled # explicitly disabled
else (DISABLE_CONTEXT_SWITCHING) else (DISABLE_CONTEXT_SWITCHING)
...@@ -355,8 +359,10 @@ endmacro () ...@@ -355,8 +359,10 @@ endmacro ()
toYesNo(ENABLE_DEBUG DEBUG_MODE_STR) toYesNo(ENABLE_DEBUG DEBUG_MODE_STR)
toYesNo(ENABLE_OPENCL BUILD_OPENCL_STR) toYesNo(ENABLE_OPENCL BUILD_OPENCL_STR)
toYesNo(DISABLE_MEM_MANAGEMENT DISABLE_MEM_MANAGEMENT_STR)
invertYesNo(CPPA_NO_EXAMPLES BUILD_EXAMPLES) invertYesNo(CPPA_NO_EXAMPLES BUILD_EXAMPLES)
invertYesNo(CPPA_NO_UNIT_TESTS BUILD_UNIT_TESTS) invertYesNo(CPPA_NO_UNIT_TESTS BUILD_UNIT_TESTS)
invertYesNo(DISABLE_MEM_MANAGEMENT_STR WITH_MEM_MANAGEMENT)
if (NOT "${CPPA_BUILD_STATIC}" STREQUAL "yes") if (NOT "${CPPA_BUILD_STATIC}" STREQUAL "yes")
set(CPPA_BUILD_STATIC "no") set(CPPA_BUILD_STATIC "no")
...@@ -383,6 +389,7 @@ message("\n====================| Build Summary |====================" ...@@ -383,6 +389,7 @@ message("\n====================| Build Summary |===================="
"\nBuild static: ${CPPA_BUILD_STATIC}" "\nBuild static: ${CPPA_BUILD_STATIC}"
"\nBulid static only: ${CPPA_BUILD_STATIC_ONLY}" "\nBulid static only: ${CPPA_BUILD_STATIC_ONLY}"
"\nBuild OpenCL: ${BUILD_OPENCL_STR}" "\nBuild OpenCL: ${BUILD_OPENCL_STR}"
"\nWith mem. mgmt.: ${WITH_MEM_MANAGEMENT}"
"\n" "\n"
"\nCXX: ${CMAKE_CXX_COMPILER}" "\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${build_type}}" "\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${build_type}}"
......
...@@ -35,6 +35,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]... ...@@ -35,6 +35,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--build-static build libcppa as static and shared library --build-static build libcppa as static and shared library
--build-static-only build libcppa as static library only --build-static-only build libcppa as static library only
--with-opencl build libcppa with OpenCL support --with-opencl build libcppa with OpenCL support
--without-memory-management build libcppa without memory management
Installation Directories: Installation Directories:
--prefix=PREFIX installation directory [/usr/local] --prefix=PREFIX installation directory [/usr/local]
...@@ -163,6 +164,9 @@ while [ $# -ne 0 ]; do ...@@ -163,6 +164,9 @@ while [ $# -ne 0 ]; do
--with-opencl) --with-opencl)
append_cache_entry ENABLE_OPENCL BOOL true append_cache_entry ENABLE_OPENCL BOOL true
;; ;;
--without-memory-management)
append_cache_entry DISABLE_MEM_MANAGEMENT BOOL true
;;
--with-cppa-log-level=*) --with-cppa-log-level=*)
level=$(echo "$optarg" | tr '[:lower:]' '[:upper:]') level=$(echo "$optarg" | tr '[:lower:]' '[:upper:]')
case $level in case $level in
......
...@@ -47,12 +47,18 @@ namespace cppa { namespace detail { ...@@ -47,12 +47,18 @@ namespace cppa { namespace detail {
namespace { namespace {
constexpr size_t s_alloc_size = 1024*1024; // allocate ~1mb chunks constexpr size_t s_alloc_size = 1024*1024; // allocate ~1mb chunks
constexpr size_t s_min_elements = 5; // don't create less than 5 elements constexpr size_t s_cache_size = 10*1024*1024; // cache about 10mb per thread
constexpr size_t s_cache_size = 10*1024*1024; // cache about 10mb per thread constexpr size_t s_min_elements = 5; // don't create < 5 elements
} // namespace <anonymous> } // namespace <anonymous>
struct disposer {
inline void operator()(memory_managed* ptr) const {
ptr->request_deletion();
}
};
class instance_wrapper { class instance_wrapper {
public: public:
...@@ -83,6 +89,36 @@ class memory_cache { ...@@ -83,6 +89,36 @@ class memory_cache {
}; };
class instance_wrapper;
template<typename T>
class basic_memory_cache;
#ifdef CPPA_DISABLE_MEM_MANAGEMENT
class memory {
memory() = delete;
public:
/*
* @brief Allocates storage, initializes a new object, and returns
* the new instance.
*/
template<typename T, typename... Ts>
static T* create(Ts&&... args) {
return new T (std::forward<Ts>(args)...);
}
static inline memory_cache* get_cache_map_entry(const std::type_info*) {
return nullptr;
}
};
#else // CPPA_DISABLE_MEM_MANAGEMENT
template<typename T> template<typename T>
class basic_memory_cache : public memory_cache { class basic_memory_cache : public memory_cache {
...@@ -163,12 +199,6 @@ class basic_memory_cache : public memory_cache { ...@@ -163,12 +199,6 @@ class basic_memory_cache : public memory_cache {
}; };
struct disposer {
inline void operator()(memory_managed* ptr) const {
ptr->request_deletion();
}
};
class memory { class memory {
memory() = delete; memory() = delete;
...@@ -209,6 +239,8 @@ class memory { ...@@ -209,6 +239,8 @@ class memory {
}; };
#endif // CPPA_DISABLE_MEM_MANAGEMENT
} } // namespace cppa::detail } } // namespace cppa::detail
#endif // CPPA_MEMORY_HPP #endif // CPPA_MEMORY_HPP
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <type_traits>
#include "cppa/util/type_traits.hpp"
namespace cppa { namespace util { namespace cppa { namespace util {
...@@ -42,14 +45,22 @@ std::vector<std::string> split(const std::string& str, ...@@ -42,14 +45,22 @@ std::vector<std::string> split(const std::string& str,
bool keep_empties = true); bool keep_empties = true);
template<typename Iterator> template<typename Iterator>
std::string join(Iterator begin, Iterator end) { typename std::enable_if<is_forward_iterator<Iterator>::value,std::string>::type
join(Iterator begin, Iterator end, const std::string& glue = "") {
std::string result; std::string result;
std::for_each(begin, end, [&](const std::string& str) { std::for_each(begin, end, [&](const std::string& str) {
if (!result.empty()) result += glue;
result += str; result += str;
}); });
return result; return result;
} }
template<typename Container>
typename std::enable_if<is_iterable<Container>::value,std::string>::type
join(const Container& c, const std::string& glue = "") {
return join(c.begin(), c.end(), glue);
}
} } // namespace cppa::util } } // namespace cppa::util
#endif // CPPA_UTIL_SPLIT_HPP #endif // CPPA_UTIL_SPLIT_HPP
...@@ -36,6 +36,12 @@ ...@@ -36,6 +36,12 @@
using namespace std; using namespace std;
#ifdef CPPA_DISABLE_MEM_MANAGEMENT
int cppa_memory_keep_compiler_happy() { return 0; }
#else // CPPA_DISABLE_MEM_MANAGEMENT
namespace cppa { namespace detail { namespace cppa { namespace detail {
namespace { namespace {
...@@ -84,17 +90,6 @@ void memory::add_cache_map_entry(const type_info* tinf, memory_cache* instance) ...@@ -84,17 +90,6 @@ void memory::add_cache_map_entry(const type_info* tinf, memory_cache* instance)
instance_wrapper::~instance_wrapper() { } instance_wrapper::~instance_wrapper() { }
//pair<instance_wrapper*, void*> memory::allocate(const type_info* type) {
// return get_cache_map_entry(type)->allocate();
//}
//recursive_queue_node* memory::new_queue_node() {
// typedef recursive_queue_node type;
// return get_cache_map_entry(&typeid(type))->typed_new<type>();
//}
//void memory::deallocate(const type_info* type, void* ptr) {
// return get_cache_map_entry(type)->deallocate(ptr);
//}
} } // namespace cppa::detail } } // namespace cppa::detail
#endif // CPPA_DISABLE_MEM_MANAGEMENT
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment