| 113 | } |
| 114 | |
| 115 | void enqueue(std::function<void()> f) { |
| 116 | if (thread.get_id() == std::this_thread::get_id()) { |
| 117 | f(); |
| 118 | return; |
| 119 | } |
| 120 | { |
| 121 | std::lock_guard<std::mutex> lock(mutex); |
| 122 | tasks.emplace(f); |
| 123 | } |
| 124 | ssize_t res = write(function_queue_fd, &CMD_FUNCTION, sizeof(CMD_FUNCTION)); |
| 125 | if (res < 0) { |
| 126 | LOGE("Unable to write to pipe: %d", errno); |
| 127 | } |
| 128 | if (res != sizeof(CMD_FUNCTION)) { |
| 129 | LOGE("Unable to write command fully to pipe"); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | void run() { |
| 134 | LOGI("AndroidThread Looper thread started."); |
no outgoing calls
no test coverage detected