MCPcopy Create free account
hub / github.com/ermak-dev/cloudpub / insert

Method insert

common/src/fair_channel.rs:60–87  ·  view source on GitHub ↗

Inserts a new item into the queue, ensuring spatial distancing between items of the same group. Returns true if inserted successfully, false if group is full.

(&mut self, value: Arc<V>)

Source from the content-addressed store, hash-verified

58 /// Inserts a new item into the queue, ensuring spatial distancing between items of the same group.
59 /// Returns true if inserted successfully, false if group is full.
60 pub fn insert(&mut self, value: Arc<V>) -> bool {
61 //value.trace_message("INSERT");
62 match value.group_id() {
63 None => {
64 // Control group (group_id is None)
65 self.ctrl_group.push_back(value);
66 true
67 }
68 Some(group_id) => {
69 // Regular group
70 if let Some(group) = self
71 .groups
72 .iter_mut()
73 .find(|group| group.front().map(|v| v.group_id()) == Some(Some(group_id)))
74 {
75 if group.len() >= self.max_group_size {
76 return false; // Group is full
77 }
78 group.push_back(value);
79 } else {
80 let mut new_group = VecDeque::new();
81 new_group.push_back(value);
82 self.groups.push(new_group);
83 }
84 true
85 }
86 }
87 }
88
89 #[inline(always)]
90 pub fn pop(&mut self) -> Option<Arc<V>> {

Callers 11

main_loopFunction · 0.80
start_httpdFunction · 0.80
registerMethod · 0.80
newMethod · 0.80
register_sessionMethod · 0.80
acquire_leaseMethod · 0.80
sendMethod · 0.80
try_sendMethod · 0.80
test_spaced_fairnessFunction · 0.80
handshakeMethod · 0.80

Calls 2

lenMethod · 0.80
group_idMethod · 0.45

Tested by 1

test_spaced_fairnessFunction · 0.64