void Execute (const NanAsyncProgressWorker::ExecutionProgress& progress) { input_event event; struct pollfd fds[1]; fds[0].fd = open (filename.c_str(), O_RDONLY ); fds[0].events = POLLIN; while(LOOP_STARTED) { if ( poll(fds, 1, 100) > 0 ){ read(fds[0].fd, (char *)&event, sizeof(input_event)); uv_mutex_lock(&queue_lock); event_queue.push (event); uv_mutex_unlock(&queue_lock); progress.Send(NULL, 0); } } }
void Execute (const NanAsyncProgressWorker::ExecutionProgress& progress) { for (int i = 0; i < iters; ++i) { progress.Send(reinterpret_cast<const char*>(&i), sizeof(int)); Sleep(milliseconds); } }