Simplify reader_wait and fix some includes.
GitOrigin-RevId: 32a91a6aa25934b2eeeddd99470a24871f38d219
This commit is contained in:
parent
3745cec3cb
commit
56f5f4e263
@ -13,7 +13,6 @@
|
||||
#include "td/utils/crypto.h"
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/MpscPollableQueue.h"
|
||||
#include "td/utils/port/Poll.h"
|
||||
#include "td/utils/port/PollFlags.h"
|
||||
#include "td/utils/port/thread.h"
|
||||
|
||||
|
@ -13,11 +13,6 @@
|
||||
|
||||
#include "td/utils/SpinLock.h"
|
||||
|
||||
#if !TD_WINDOWS
|
||||
#include <poll.h>
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace td {
|
||||
@ -79,21 +74,14 @@ class MpscPollableQueue {
|
||||
}
|
||||
}
|
||||
|
||||
// Just example of usage
|
||||
#if !TD_WINDOWS
|
||||
// Just an example of usage
|
||||
int reader_wait() {
|
||||
int res;
|
||||
|
||||
while ((res = reader_wait_nonblock()) == 0) {
|
||||
// TODO: reader_flush?
|
||||
pollfd fd;
|
||||
fd.fd = reader_get_event_fd().get_poll_info().native_fd().fd();
|
||||
fd.events = POLLIN;
|
||||
poll(&fd, 1, -1);
|
||||
reader_get_event_fd().wait(1000);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
SpinLock lock_;
|
||||
|
@ -17,9 +17,9 @@ char disable_linker_warning_about_empty_file_event_fd_bsd_cpp TD_UNUSED;
|
||||
#include "td/utils/Slice.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <poll.h>
|
||||
|
||||
namespace td {
|
||||
namespace detail {
|
||||
|
@ -17,8 +17,8 @@ char disable_linker_warning_about_empty_file_event_fd_linux_cpp TD_UNUSED;
|
||||
#include "td/utils/Slice.h"
|
||||
|
||||
#include <sys/eventfd.h>
|
||||
#include <unistd.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace td {
|
||||
namespace detail {
|
||||
|
@ -11,11 +11,6 @@
|
||||
|
||||
#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED
|
||||
|
||||
#if !TD_WINDOWS
|
||||
#include <poll.h>
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#include <atomic>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
@ -393,18 +388,14 @@ class PollQueue : public QueueT {
|
||||
return res;
|
||||
}
|
||||
|
||||
// Just example of usage
|
||||
#if !TD_WINDOWS
|
||||
// Just an example of usage
|
||||
int reader_wait() {
|
||||
int res;
|
||||
|
||||
while ((res = reader_wait_nonblock()) == 0) {
|
||||
// TODO: reader_flush?
|
||||
reader_get_event_fd().wait(1000);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
EventFd event_fd_;
|
||||
|
@ -35,7 +35,7 @@ TEST(Port, files) {
|
||||
const int ITER_COUNT = 1000;
|
||||
for (int i = 0; i < ITER_COUNT; i++) {
|
||||
walk_path(main_dir,
|
||||
[&](CSlice name, bool is_directory) mutable {
|
||||
[&](CSlice name, bool is_directory) {
|
||||
if (!is_directory) {
|
||||
ASSERT_TRUE(name == fd_path || name == fd2_path);
|
||||
}
|
||||
|
Reference in New Issue
Block a user