pi mutex template

Signed-off-by: liuchungang <liuchungang@hisilicon.com>
This commit is contained in:
Marquez_esta
2025-12-11 20:35:45 +08:00
parent 055fb96b7b
commit e23e8df39f
5 changed files with 37 additions and 16 deletions
+12 -3
View File
@@ -47,7 +47,8 @@
"//foundation/resourceschedule/qos_manager/services:concurrentsvc",
"//foundation/resourceschedule/qos_manager/frameworks/concurrent_task_client:concurrent_task_client",
"//foundation/resourceschedule/qos_manager/qos:qos",
"//foundation/resourceschedule/qos_manager/frameworks/native:qos_ndk"
"//foundation/resourceschedule/qos_manager/frameworks/native:qos_ndk",
"//foundation/resourceschedule/qos_manager/qos:pi_mutex"
],
"inner_kits": [
{
@@ -63,11 +64,19 @@
"header": {
"header_base": "//foundation/resourceschedule/qos_manager/interfaces/inner_api/",
"header_files": [
"qos.h",
"pi_mutex.h"
"qos.h"
]
},
"name": "//foundation/resourceschedule/qos_manager/qos:qos"
},
{
"header": {
"header_base": "//foundation/resourceschedule/qos_manager/interfaces/inner_api/",
"header_files": [
"pi_mutex.h"
]
},
"name": "//foundation/resourceschedule/qos_manager/qos:pi_mutex"
}
],
"test": [
@@ -184,7 +184,7 @@ void ConcurrentTaskClient::StopRemoteObject()
clientService_ = nullptr;
}
int ConcurrentTaskClient::SetSystemQoS(int tid, int level)
int ConcurrentTaskClient::SetSystemQoS([[maybe_unused]] int tid, [[maybe_unused]] int level)
{
return 0;
}
+14 -8
View File
@@ -13,21 +13,27 @@
* limitations under the License.
*/
#ifndef QOS_PI_MUETX_H
#define QOS_PI_MUETX_H
#ifndef QOS_MANAGER_PI_MUETX_H
#define QOS_MANAGER_PI_MUETX_H
#include <pthread.h>
#include <mutex>
#include <type_traits>
namespace OHOS {
namespace QOS {
class PiMutex : public std::mutex {
namespace PiMutex {
template<class, class = std::void_t<>>
struct HasType : std::false_type {};
template<class T>
struct HasType<T, std::void_t<typename T::native_handle_type>> : std::true_type {};
template<class Mutex>
class PiMutex : public Mutex {
public:
PiMutex()
{
if constexpr (std::is_same_v<std::mutex::native_handle_type, pthread_mutex_t*>) {
std::mutex::native_handle_type handle = std::mutex::native_handle();
if constexpr (HasType<Mutex> && std::is_same_v<Mutex::native_handle_type, pthread_mutex_t*>) {
typename Mutex::native_handle_type handle = Mutex::native_handle();
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
@@ -43,4 +49,4 @@ public:
} // namespace QOS
} // namespace OHOS
#endif // QOS_PI_MUETX_H
#endif // QOS_MANAGER_PI_MUETX_H
+6
View File
@@ -56,3 +56,9 @@ ohos_shared_library("qos") {
subsystem_name = "resourceschedule"
part_name = "qos_manager"
}
ohos_shared_headers("pi_mutex") {
include_dirs = [ "../interfaces/inner_api/" ]
subsystem_name = "resourceschedule"
part_name = "qos_manager"
}
+4 -4
View File
@@ -127,22 +127,22 @@ int GetQosForOtherThread(enum QosLevel &level, int tid)
return QosController::GetInstance().GetThreadQosForOtherThread(level, tid);
}
int AddThreadToProcRtg(int tid)
int AddThreadToProcRtg([[maybe_unused]] int tid)
{
return 0;
}
int AddThreadsToProcRtg(int tid[5], int size)
int AddThreadsToProcRtg([[maybe_unused]] int tid[5], [[maybe_unused]] int size)
{
return 0;
}
int RemoveThreadFromProcRtg(int tid)
int RemoveThreadFromProcRtg([[maybe_unused]] int tid)
{
return 0;
}
int RemoveThreadsFromProcRtg(int tid[5], int size)
int RemoveThreadsFromProcRtg([[maybe_unused]] int tid[5], [[maybe_unused]] int size)
{
return 0;
}