void PtrQueueSet::deallocate_buffer(void** buf) { assert(_sz > 0, "Didn't set a buffer size."); MutexLockerEx x(_fl_owner->_fl_lock, Mutex::_no_safepoint_check_flag); BufferNode *node = BufferNode::make_node_from_buffer(buf); node->set_next(_fl_owner->_buf_free_list); _fl_owner->_buf_free_list = node; _fl_owner->_buf_free_list_sz++; }
int PtrQueueSet::completed_buffers_list_length() { int n = 0; BufferNode* cbn = _completed_buffers_head; while (cbn != NULL) { n++; cbn = cbn->next(); } return n; }
Node_ptr Array<T>::getNode() const { if (node->isBuffer()) { BufferNode<T> *bufNode = reinterpret_cast<BufferNode<T> *>(node.get()); unsigned bytes = this->getDataDims().elements() * sizeof(T); bufNode->setData(data, bytes, getOffset(), dims().get(), strides().get(), isLinear()); } return node; }
Node_ptr Array<T>::getNode() { if (node->isBuffer()) { unsigned bytes = this->getDataDims().elements() * sizeof(T); BufferNode<T> *bufNode = reinterpret_cast<BufferNode<T> *>(node.get()); Param<T> param = *this; bufNode->setData(param, data, bytes, isLinear()); } return node; }
void DirtyCardQueueSet::apply_closure_to_all_completed_buffers() { BufferNode* nd = _completed_buffers_head; while (nd != NULL) { bool b = DirtyCardQueue::apply_closure_to_buffer(_closure, BufferNode::make_buffer_from_node(nd), 0, _sz, false); guarantee(b, "Should not stop early."); nd = nd->next(); } }
void DirtyCardQueueSet::par_apply_closure_to_all_completed_buffers(CardTableEntryClosure* cl) { BufferNode* nd = _cur_par_buffer_node; while (nd != NULL) { BufferNode* next = nd->next(); void* actual = Atomic::cmpxchg_ptr(next, &_cur_par_buffer_node, nd); if (actual == nd) { bool b = apply_closure_to_buffer(cl, nd, false); guarantee(b, "Should not stop early."); nd = next; } else { nd = static_cast<BufferNode*>(actual); } } }
// Deallocates any completed log buffers void DirtyCardQueueSet::clear() { BufferNode* buffers_to_delete = NULL; { MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); while (_completed_buffers_head != NULL) { BufferNode* nd = _completed_buffers_head; _completed_buffers_head = nd->next(); nd->set_next(buffers_to_delete); buffers_to_delete = nd; } _n_completed_buffers = 0; _completed_buffers_tail = NULL; DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked()); } while (buffers_to_delete != NULL) { BufferNode* nd = buffers_to_delete; buffers_to_delete = nd->next(); deallocate_buffer(nd); } }
BufferNode* DirtyCardQueueSet::get_completed_buffer(int stop_at) { BufferNode* nd = NULL; MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); if ((int)_n_completed_buffers <= stop_at) { _process_completed = false; return NULL; } if (_completed_buffers_head != NULL) { nd = _completed_buffers_head; _completed_buffers_head = nd->next(); if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL; _n_completed_buffers--; assert(_n_completed_buffers >= 0, "Invariant"); } debug_only(assert_completed_buffer_list_len_correct_locked()); return nd; }
void PtrQueueSet::enqueue_complete_buffer(void** buf, size_t index) { MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); BufferNode* cbn = BufferNode::new_from_buffer(buf); cbn->set_index(index); if (_completed_buffers_tail == NULL) { assert(_completed_buffers_head == NULL, "Well-formedness"); _completed_buffers_head = cbn; _completed_buffers_tail = cbn; } else { _completed_buffers_tail->set_next(cbn); _completed_buffers_tail = cbn; } _n_completed_buffers++; if (!_process_completed && _process_completed_threshold >= 0 && _n_completed_buffers >= _process_completed_threshold) { _process_completed = true; if (_notify_when_complete) _cbl_mon->notify(); } debug_only(assert_completed_buffer_list_len_correct_locked()); }
void TsFrameBufferBase::insertNewNode(TsFrameBase *packet) { if(sync_status == buffer_cannot_be_synced) { insertFailed(packet); return; } if(sync_status == buffer_syncing_waiting_for_pts) { if(packet->PTS < sync_PTS) { insertFailed(packet); return; } else if(packet->PTS == sync_PTS) { sync_status = buffer_syncing_pts_received; } else { printDebugMessage("greater than the expected PTS " + buffer_id, STATUS); sync_status = buffer_syncing_pts_received; } } unsigned int first_PTS = getFirstPTS(); unsigned int received_PTS = packet->PTS; unsigned int expected_PTS = last->packet->PTS + pts_per_frame; int frame_difference = ((int)received_PTS - (int)expected_PTS) / (int)pts_per_frame; if(frame_difference == 0) { packet->PTS = expected_PTS; received_PTS = packet->PTS; } if(received_PTS > expected_PTS) { printDebugMessage("buffer " + buffer_id + " missed " + to_str(frame_difference) + " frames in insert", WARNING); insertNullFrame(frame_difference, expected_PTS); } writeDebugMessage(buffer_id + "_insert.txt", to_str(received_PTS) + "\t" + now_str() + " " + getStatusStr() + " " + to_str(getFillRatio()) + "%" + " " + to_str(current_size) + "/" + to_str(total_size), STATUS); if(received_PTS >= expected_PTS) { insertTail(packet); packet->setArrivalTime(); } else { if(received_PTS < first_PTS) { /*if(frame_difference + FRAME_NUMBER_FOR_LOOP_DETECTION < 0) { loop_on = true; printDebugMessage("buffer " + buffer_id + " loop at " + now_str(), WARNING); insertTail(packet); packet->setArrivalTime(); } else {*/ printDebugMessage("buffer " + buffer_id + " very early PTS", WARNING); insertFailed(packet); //} } else { lock(); printDebugMessage("buffer " + buffer_id + " early PTS", WARNING); BufferNode<TsFrameBase> *current; BufferNode<TsFrameBase> *prev = first; for(current = first; current != NULL; current = current->next) { if(current->packet->PTS < packet->PTS) { prev = current; } else if(current->packet->PTS == packet->PTS) { printDebugMessage("buffer " + buffer_id + " existing PTS", WARNING); insertFailed(packet); return; } else { break; } } prev->insertAfter(new BufferNode<TsFrameBase>(packet)); insertSuccessful(packet); packet->setArrivalTime(); } } }