mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
[1/n] optimize CPU code.
Limit the amount of atomic operations while decrementing ref count from 2 to 1 Change-Id: I0e9e9f07abd1aa62a3967ce4f83ffe2cc288765a
This commit is contained in:
committed by
sys_ocldev
parent
f13bc4d462
commit
5167e3da69
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -54,6 +54,10 @@ class RefCounter {
|
||||
return (curr == 0);
|
||||
}
|
||||
|
||||
CT decAndReturnCurrent() {
|
||||
return --val;
|
||||
}
|
||||
|
||||
bool peekIsZero() const {
|
||||
return (val == 0);
|
||||
}
|
||||
@@ -144,8 +148,9 @@ class ReferenceTrackedObject {
|
||||
|
||||
unique_ptr_if_unused<DerivedClass> decRefInternal() {
|
||||
auto customDeleter = tryGetCustomDeleter();
|
||||
bool unused = refInternal.dec();
|
||||
UNRECOVERABLE_IF(refInternal.peek() < 0);
|
||||
auto current = refInternal.decAndReturnCurrent();
|
||||
bool unused = (current == 0);
|
||||
UNRECOVERABLE_IF(current < 0);
|
||||
return unique_ptr_if_unused<DerivedClass>(static_cast<DerivedClass *>(this), unused, customDeleter);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user