Example #1
0
void grpc_metadata_batch_merge(grpc_metadata_batch *target,
                               grpc_metadata_batch *add) {
  grpc_linked_mdelem *l;
  grpc_linked_mdelem *next;
  for (l = add->list.head; l; l = next) {
    next = l->next;
    link_tail(&target->list, l);
  }
  for (l = add->garbage.head; l; l = next) {
    next = l->next;
    link_tail(&target->garbage, l);
  }
}
Example #2
0
void FreeList<Chunk>::remove_chunk(Chunk*fc) {
   assert_proper_lock_protection();
   assert(head() != NULL, "Remove from empty list");
   assert(fc != NULL, "Remove a NULL chunk");
   assert(size() == fc->size(), "Wrong list");
   assert(head() == NULL || head()->prev() == NULL, "list invariant");
   assert(tail() == NULL || tail()->next() == NULL, "list invariant");

   Chunk* prevFC = fc->prev();
   Chunk* nextFC = fc->next();
   if (nextFC != NULL) {
     // The chunk fc being removed has a "next".  Set the "next" to the
     // "prev" of fc.
     nextFC->link_prev(prevFC);
   } else { // removed tail of list
     link_tail(prevFC);
   }
   if (prevFC == NULL) { // removed head of list
     link_head(nextFC);
     assert(nextFC == NULL || nextFC->prev() == NULL,
       "Prev of head should be NULL");
   } else {
     prevFC->link_next(nextFC);
     assert(tail() != prevFC || prevFC->next() == NULL,
       "Next of tail should be NULL");
   }
   decrement_count();
   assert(((head() == NULL) + (tail() == NULL) + (count() == 0)) % 3 == 0,
          "H/T/C Inconsistency");
   // clear next and prev fields of fc, debug only
   NOT_PRODUCT(
     fc->link_prev(NULL);
     fc->link_next(NULL);
   )
Example #3
0
Chunk_t* FreeList<Chunk_t>::get_chunk_at_head() {
  assert_proper_lock_protection();
  assert(head() == NULL || head()->prev() == NULL, "list invariant");
  assert(tail() == NULL || tail()->next() == NULL, "list invariant");
  Chunk_t* fc = head();
  if (fc != NULL) {
    Chunk_t* nextFC = fc->next();
    if (nextFC != NULL) {
      // The chunk fc being removed has a "next".  Set the "next" to the
      // "prev" of fc.
      nextFC->link_prev(NULL);
    } else { // removed tail of list
      link_tail(NULL);
    }
    link_head(nextFC);
    decrement_count();
  }
  assert(head() == NULL || head()->prev() == NULL, "list invariant");
  assert(tail() == NULL || tail()->next() == NULL, "list invariant");
  return fc;
}
Example #4
0
// Remove this chunk from the list
void FreeList::removeChunk(FreeChunk*fc) {
    assert_proper_lock_protection();
    assert(head() != NULL, "Remove from empty list");
    assert(fc != NULL, "Remove a NULL chunk");
    assert(size() == fc->size(), "Wrong list");
    assert(head() == NULL || head()->prev() == NULL, "list invariant");
    assert(tail() == NULL || tail()->next() == NULL, "list invariant");

    FreeChunk* prevFC = fc->prev();
    FreeChunk* nextFC = fc->next();
    if (nextFC != NULL) {
        // The chunk fc being removed has a "next".  Set the "next" to the
        // "prev" of fc.
        nextFC->linkPrev(prevFC);
    } else { // removed tail of list
        link_tail(prevFC);
    }
    if (prevFC == NULL) { // removed head of list
        link_head(nextFC);
        assert(nextFC == NULL || nextFC->prev() == NULL,
               "Prev of head should be NULL");
    } else {
        prevFC->linkNext(nextFC);
        assert(tail() != prevFC || prevFC->next() == NULL,
               "Next of tail should be NULL");
    }
    decrement_count();
#define TRAP_CODE 1
#if TRAP_CODE
    if (head() == NULL) {
        guarantee(tail() == NULL, "INVARIANT");
        guarantee(count() == 0, "INVARIANT");
    }
#endif
    // clear next and prev fields of fc, debug only
    NOT_PRODUCT(
        fc->linkPrev(NULL);
        fc->linkNext(NULL);
    )
Example #5
0
 void link_tail(T* element) {
   link_tail(&(element->*LinkMember));
 }
Example #6
0
void grpc_metadata_batch_link_tail(grpc_metadata_batch *batch,
                                   grpc_linked_mdelem *storage) {
  link_tail(&batch->list, storage);
}