mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-21 05:45:23 -04:00
Description:fix dhardware cpu 100
Match-id-18b6d4ff4f9f2694b055a475898d0f3b152c5b92
This commit is contained in:
@@ -39,7 +39,7 @@ namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
namespace {
|
||||
const char *DEVICE_PATH = "/dev/input";
|
||||
const uint32_t SLEEP_TIME_MS = 100000;
|
||||
const uint32_t SLEEP_TIME_US = 100 * 1000;
|
||||
const uint32_t ERROR_MSG_MAX_LEN = 256;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ size_t InputHub::StartCollectInputEvents(RawEvent* buffer, size_t bufferSize)
|
||||
break;
|
||||
}
|
||||
|
||||
if (RefreshEpollItem() < 0) {
|
||||
if (RefreshEpollItem(false) < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -306,7 +306,7 @@ size_t InputHub::StartCollectInputHandler(InputDeviceEvent* buffer, size_t buffe
|
||||
if (count > 0) {
|
||||
break;
|
||||
}
|
||||
if (RefreshEpollItem() < 0) {
|
||||
if (RefreshEpollItem(true) < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -353,7 +353,7 @@ void InputHub::GetDeviceHandler()
|
||||
}
|
||||
}
|
||||
|
||||
int32_t InputHub::RefreshEpollItem()
|
||||
int32_t InputHub::RefreshEpollItem(bool isSleep)
|
||||
{
|
||||
pendingEventIndex_ = 0;
|
||||
int pollResult = epoll_wait(epollFd_, mPendingEventItems, EPOLL_MAX_EVENTS, 0);
|
||||
@@ -371,12 +371,15 @@ int32_t InputHub::RefreshEpollItem()
|
||||
// Hopefully the error is transient.
|
||||
if (errno != EINTR) {
|
||||
DHLOGE("poll failed (errno=%d)\n", errno);
|
||||
usleep(SLEEP_TIME_MS);
|
||||
usleep(SLEEP_TIME_US);
|
||||
}
|
||||
} else {
|
||||
// Some events occurred.
|
||||
pendingEventCount_ = pollResult;
|
||||
}
|
||||
if (isSleep) {
|
||||
usleep(SLEEP_TIME_US);
|
||||
}
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ private:
|
||||
size_t GetEvents(RawEvent* buffer, size_t bufferSize);
|
||||
size_t ReadInputEvent(int32_t readSize, Device& device);
|
||||
void GetDeviceHandler();
|
||||
int32_t RefreshEpollItem();
|
||||
int32_t RefreshEpollItem(bool isSleep);
|
||||
|
||||
void ScanInputDevices(const std::string& dirname);
|
||||
int32_t OpenInputDeviceLocked(const std::string& devicePath);
|
||||
|
||||
Reference in New Issue
Block a user