2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-23 18:57:37 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
2018-09-18 15:11:08 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/flush_stamp.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
FlushStampTracker::FlushStampTracker(bool allocateStamp) {
|
|
|
|
if (allocateStamp) {
|
|
|
|
flushStampSharedHandle = new FlushStampTrackingObj();
|
|
|
|
flushStampSharedHandle->incRefInternal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FlushStampTracker::~FlushStampTracker() {
|
|
|
|
if (flushStampSharedHandle) {
|
|
|
|
flushStampSharedHandle->decRefInternal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FlushStamp FlushStampTracker::peekStamp() const {
|
2018-02-02 21:50:09 +08:00
|
|
|
if (flushStampSharedHandle->initialized) {
|
|
|
|
return flushStampSharedHandle->flushStamp;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void FlushStampTracker::setStamp(FlushStamp stamp) {
|
2018-02-05 20:34:57 +08:00
|
|
|
if (stamp != 0) {
|
|
|
|
flushStampSharedHandle->flushStamp = stamp;
|
|
|
|
flushStampSharedHandle->initialized = true;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void FlushStampTracker::replaceStampObject(FlushStampTrackingObj *stampObj) {
|
|
|
|
if (stampObj) {
|
|
|
|
stampObj->incRefInternal();
|
|
|
|
if (flushStampSharedHandle) {
|
|
|
|
flushStampSharedHandle->decRefInternal();
|
|
|
|
}
|
|
|
|
flushStampSharedHandle = stampObj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlushStampUpdateHelper::insert(FlushStampTrackingObj *stampObj) {
|
|
|
|
if (stampObj) {
|
|
|
|
flushStampsToUpdate.push_back(stampObj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-24 21:50:41 +08:00
|
|
|
void FlushStampUpdateHelper::updateAll(const FlushStamp &flushStamp) {
|
2017-12-21 07:45:38 +08:00
|
|
|
for (const auto &stamp : flushStampsToUpdate) {
|
2018-02-02 21:50:09 +08:00
|
|
|
stamp->flushStamp = flushStamp;
|
2018-02-05 20:34:57 +08:00
|
|
|
stamp->initialized = true;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t FlushStampUpdateHelper::size() const {
|
|
|
|
return flushStampsToUpdate.size();
|
|
|
|
}
|