Skip to content

Commit ee19802

Browse files
committed
peer review feedback
1 parent a9a76e3 commit ee19802

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

rtb/datacache/entity_cache.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ struct retriever<Tag,std::vector<std::shared_ptr<Serializable>>> {
119119

120120
inline constexpr size_t ENTITY_CACHE_DEFAULT_MEMORY_SIZE = 67108864 /* 64 MB*/;
121121
inline constexpr size_t ENTITY_CACHE_DEFAULT_MEMORY_GROW_INCREMENT = 67108864 /* 64 MB*/;
122+
inline constexpr uint64_t ENTITY_CACHE_DEFAULT_LOCK_TIMEOUT_S = 10;
122123
template<typename Memory, template <class,class...> class Container, typename ...T>
123124
class entity_cache
124125
{
@@ -134,7 +135,8 @@ class entity_cache
134135

135136
/** Can set memory_grow_increment=0 to prevent cache from growing */
136137
explicit entity_cache(std::string name, size_t const memory_size = ENTITY_CACHE_DEFAULT_MEMORY_SIZE,
137-
size_t const memory_grow_increment = ENTITY_CACHE_DEFAULT_MEMORY_GROW_INCREMENT)
138+
size_t const memory_grow_increment = ENTITY_CACHE_DEFAULT_MEMORY_GROW_INCREMENT,
139+
uint32_t lock_timeout_s = ENTITY_CACHE_DEFAULT_LOCK_TIMEOUT_S)
138140
: _segment_ptr(), _container_ptr(), _store_name(), _cache_name(std::move(name)),
139141
_named_mutex(bip::open_or_create, (_cache_name + "_mutex").c_str()),
140142
_memory_grow_increment{memory_grow_increment} {
@@ -143,7 +145,7 @@ class entity_cache
143145
std::string data_base_dir = "/tmp/CACHE";
144146

145147
auto guard = bip::scoped_lock{_named_mutex, bip::defer_lock};
146-
VAV_REQUIRE(guard.try_lock_for(boost::chrono::seconds(10)));
148+
VAV_REQUIRE(guard.try_lock_for(boost::chrono::seconds(lock_timeout_s)));
147149

148150
_store_name = Memory::convert_base_dir(data_base_dir) + _cache_name;
149151
_segment_ptr.reset(Memory::open_or_create_segment(_store_name.c_str(), memory_size));

rtb/datacache/memory_types.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
namespace mpclmi::ipc {
3131

3232
/** A variation of the Shared:
33-
* - simpler memory allocation algorithm suitable for segments storing a single node-based cotainer
33+
* - simpler memory allocation algorithm suitable for segments storing a single node-based container
3434
* - memory allocation is not thread safe, relying on external synchronization typical for entity_cache-based containers
3535
*/
36-
struct SharedVL {
36+
struct SharedSeqFitNoLock {
3737
using char_type = char;
3838
using mutex_family_type = boost::interprocess::null_mutex_family;
3939
using memory_algorithm_type = boost::interprocess::simple_seq_fit<mutex_family_type>;

0 commit comments

Comments
 (0)