mirror of
https://gitee.com/openharmony/resourceschedule_ffrt
synced 2024-12-02 10:26:58 +00:00
update watchdog struct
Signed-off-by: shengxia <496830733@qq.com>
This commit is contained in:
parent
2cf58efb1e
commit
843994c8fa
@ -19,8 +19,8 @@
|
||||
|
||||
typedef void(*ffrt_watchdog_cb)(uint64_t, const char *, uint32_t);
|
||||
FFRT_C_API void ffrt_watchdog_dumpinfo(char *buf, uint32_t len);
|
||||
FFRT_C_API void ffrt_watchdog_register(ffrt_watchdog_cb *cb, uint32_t timeout_ms, uint32_t interval_ms);
|
||||
FFRT_C_API ffrt_watchdog_cb *ffrt_watchdog_get_cb(void);
|
||||
FFRT_C_API void ffrt_watchdog_register(ffrt_watchdog_cb cb, uint32_t timeout_ms, uint32_t interval_ms);
|
||||
FFRT_C_API ffrt_watchdog_cb ffrt_watchdog_get_cb(void);
|
||||
FFRT_C_API uint32_t ffrt_watchdog_get_timeout(void);
|
||||
FFRT_C_API uint32_t ffrt_watchdog_get_interval(void);
|
||||
#endif /* FFRT_WATCHDOG_H */
|
@ -17,27 +17,17 @@
|
||||
#include "dfx/bbox/bbox.h"
|
||||
|
||||
namespace ffrt {
|
||||
constexpr uint32_t DEFAULT_TIMEOUT_MS = 30000;
|
||||
struct WatchdogCfg {
|
||||
public:
|
||||
explicit WatchdogCfg(ffrt_watchdog_cb* cb, uint32_t timeout_ms = 30000,
|
||||
uint32_t interval_ms = 30000)
|
||||
static inline WatchdogCfg* Instance()
|
||||
{
|
||||
callback = cb;
|
||||
timeout = timeout_ms;
|
||||
interval = interval_ms;
|
||||
}
|
||||
~WatchdogCfg() {}
|
||||
|
||||
uint32_t timeout;
|
||||
uint32_t interval;
|
||||
ffrt_watchdog_cb *callback;
|
||||
|
||||
static inline WatchdogCfg* Instance(ffrt_watchdog_cb* cb = nullptr, uint32_t timeout_ms = 30000,
|
||||
uint32_t interval_ms = 30000)
|
||||
{
|
||||
static WatchdogCfg inst(cb, timeout_ms, interval_ms);
|
||||
static WatchdogCfg inst;
|
||||
return &inst;
|
||||
}
|
||||
|
||||
uint32_t timeout = DEFAULT_TIMEOUT_MS;
|
||||
uint32_t interval = DEFAULT_TIMEOUT_MS;
|
||||
ffrt_watchdog_cb callback = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
@ -60,13 +50,15 @@ void ffrt_watchdog_dumpinfo(char *buf, uint32_t len)
|
||||
}
|
||||
|
||||
API_ATTRIBUTE((visibility("default")))
|
||||
void ffrt_watchdog_register(ffrt_watchdog_cb *cb, uint32_t timeout_ms, uint32_t interval_ms)
|
||||
void ffrt_watchdog_register(ffrt_watchdog_cb cb, uint32_t timeout_ms, uint32_t interval_ms)
|
||||
{
|
||||
ffrt::WatchdogCfg::Instance(cb, timeout_ms, interval_ms);
|
||||
ffrt::WatchdogCfg::Instance()->callback = cb;
|
||||
ffrt::WatchdogCfg::Instance()->timeout = timeout_ms;
|
||||
ffrt::WatchdogCfg::Instance()->interval = interval_ms;
|
||||
}
|
||||
|
||||
API_ATTRIBUTE((visibility("default")))
|
||||
ffrt_watchdog_cb *ffrt_watchdog_get_cb(void)
|
||||
ffrt_watchdog_cb ffrt_watchdog_get_cb(void)
|
||||
{
|
||||
return ffrt::WatchdogCfg::Instance()->callback;
|
||||
}
|
||||
|
@ -137,9 +137,9 @@ void QueueMonitor::CheckQueuesStatus()
|
||||
", serial task gid=" << taskId << " execution " << timeoutUs_ << "us.";
|
||||
FFRT_LOGE("%s", ss.str().c_str());
|
||||
|
||||
ffrt_watchdog_cb* func = ffrt_watchdog_get_cb();
|
||||
ffrt_watchdog_cb func = ffrt_watchdog_get_cb();
|
||||
if (func) {
|
||||
(*func)(taskId, ss.str().c_str(), ss.str().size());
|
||||
func(taskId, ss.str().c_str(), ss.str().size());
|
||||
}
|
||||
// reset timeout task timestampe for next warning
|
||||
ResetTaskTimestampAfterWarning(i, taskId);
|
||||
|
Loading…
Reference in New Issue
Block a user