Commit 0e4a78c0 authored by dchh's avatar dchh

fixed nasty bug w/ large actor classes, fixes #88

parent 6e57254e
...@@ -48,6 +48,7 @@ namespace cppa { namespace detail { ...@@ -48,6 +48,7 @@ namespace cppa { namespace detail {
namespace { namespace {
constexpr size_t s_alloc_size = 1024; // allocate ~1kb chunks constexpr size_t s_alloc_size = 1024; // allocate ~1kb chunks
constexpr size_t s_min_elements = 5; // don't create less than 5 elements
constexpr size_t s_cache_size = 10240; // cache about 10kb per thread constexpr size_t s_cache_size = 10240; // cache about 10kb per thread
} // namespace <anonymous> } // namespace <anonymous>
...@@ -96,6 +97,9 @@ class basic_memory_cache : public memory_cache { ...@@ -96,6 +97,9 @@ class basic_memory_cache : public memory_cache {
class storage : public ref_counted { class storage : public ref_counted {
static constexpr size_t ne = s_alloc_size / sizeof(T);
static constexpr size_t dsize = ne > s_min_elements ? ne : s_min_elements;
public: public:
storage() { storage() {
...@@ -110,11 +114,11 @@ class basic_memory_cache : public memory_cache { ...@@ -110,11 +114,11 @@ class basic_memory_cache : public memory_cache {
iterator begin() { return data; } iterator begin() { return data; }
iterator end() { return begin() + (s_alloc_size / sizeof(T)); } iterator end() { return begin() + dsize; }
private: private:
wrapper data[s_alloc_size / sizeof(T)]; wrapper data[dsize];
}; };
......
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