Class ShardedMap::Shard¶
Defined in File sharded_map.hpp
Nested Relationships¶
This class is a nested type of Template Class ShardedMap.
Class Documentation¶
-
class Shard¶
Public Functions
-
inline Shard(ShardedMap &sharded_map, size_t thread_id)¶
Create a new shard for the given thread.
- Parameters:
sharded_map – The sharded map to which the shard belongs.
thread_id – The thread’s id. Must be less than
thread_countin the sharded map.
-
inline void insert_or_update_direct(const K &k, InputValue &&in_value)¶
Inserts or updates a new value in the map, depending on whether.
- Parameters:
k – The key to insert or update a value for.
in_value – The value with which to insert or update.
-
inline void handle_queue_sync(bool cause_wait = true)¶
Handles this thread’s queue synchronously with other threads, inserting or updating all values in its queue.
This thread will wait until all other threads also call this method before starting to handle the queues.
- Parameters:
cause_wait – If true, this will force other threads to handle their queues when they call insert.
-
inline void handle_queue_async()¶
Handles this thread’s queue, inserting or updating all values in its queue.
Warning: This should not be called while other threads are inserting into this thread’s queue!
-
inline void insert(QueueStoredValue &&pair)¶
Inserts or updates a new value in the map.
If the value is inserted into the current thread’s map, it is inserted immediately. If not, then it is added to that thread’s queue. It will only be inserted into the map, once the thread comes around to handle its queue using the handle_queue method.
- Parameters:
pair – The key-value pair to insert or update.
-
inline void insert(const K &key, InputValue value)¶
Inserts or updates a new value in the map.
If the value is inserted into the current thread’s map, it is inserted immediately. If not, then it is added to that thread’s queue. It will only be inserted into the map, once the thread comes around to handle its queue using the handle_queue method.
- Parameters:
key – The key of the value to insert.
value – The value to associate with the key.
-
inline Shard(ShardedMap &sharded_map, size_t thread_id)¶