Skip to content

Commit

Permalink
peer review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbald committed Dec 18, 2024
1 parent a9a76e3 commit 13b02ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions rtb/datacache/entity_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ struct retriever<Tag,std::vector<std::shared_ptr<Serializable>>> {

inline constexpr size_t ENTITY_CACHE_DEFAULT_MEMORY_SIZE = 67108864 /* 64 MB*/;
inline constexpr size_t ENTITY_CACHE_DEFAULT_MEMORY_GROW_INCREMENT = 67108864 /* 64 MB*/;
inline constexpr uint64_t ENTITY_CACHE_DEFAULT_LOCK_TIMEOUT_S = 10;
template<typename Memory, template <class,class...> class Container, typename ...T>
class entity_cache
{
Expand All @@ -134,7 +135,8 @@ class entity_cache

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

auto guard = bip::scoped_lock{_named_mutex, bip::defer_lock};
VAV_REQUIRE(guard.try_lock_for(boost::chrono::seconds(10)));
VAV_REQUIRE(guard.try_lock_for(boost::chrono::seconds(lock_timeout_s)));

_store_name = Memory::convert_base_dir(data_base_dir) + _cache_name;
_segment_ptr.reset(Memory::open_or_create_segment(_store_name.c_str(), memory_size));
Expand Down
2 changes: 1 addition & 1 deletion rtb/datacache/memory_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace mpclmi::ipc {
* - simpler memory allocation algorithm suitable for segments storing a single node-based cotainer
* - memory allocation is not thread safe, relying on external synchronization typical for entity_cache-based containers
*/
struct SharedVL {
struct SharedSeqFitNoLock {
using char_type = char;
using mutex_family_type = boost::interprocess::null_mutex_family;
using memory_algorithm_type = boost::interprocess::simple_seq_fit<mutex_family_type>;
Expand Down

0 comments on commit 13b02ba

Please sign in to comment.