File indexing completed on 2025-01-05 04:37:21
0001 /* 0002 SPDX-FileCopyrightText: 2009 Joris Guisson <joris.guisson@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef KTWAKEUPPIPE_H 0007 #define KTWAKEUPPIPE_H 0008 0009 #include <QMutex> 0010 #include <ktorrent_export.h> 0011 #include <net/poll.h> 0012 #include <util/pipe.h> 0013 0014 namespace net 0015 { 0016 /** 0017 A WakeUpPipe's purpose is to wakeup a select or poll call. 0018 It works by using a pipe 0019 One end needs to be part of the poll or select, and the other end will send dummy data to it. 0020 Waking up the select or poll call. 0021 */ 0022 class KTORRENT_EXPORT WakeUpPipe : public bt::Pipe, public PollClient 0023 { 0024 public: 0025 WakeUpPipe(); 0026 ~WakeUpPipe() override; 0027 0028 /// Wake up the other socket 0029 virtual void wakeUp(); 0030 0031 /// Read all the dummy data 0032 void handleData() override; 0033 0034 int fd() const override 0035 { 0036 return readerSocket(); 0037 } 0038 0039 void reset() override; 0040 0041 /// Have we been woken up 0042 bool wokenUp() const 0043 { 0044 return woken_up; 0045 } 0046 0047 typedef QSharedPointer<WakeUpPipe> Ptr; 0048 0049 protected: 0050 mutable QMutex mutex; 0051 bool woken_up; 0052 }; 0053 0054 } 0055 0056 #endif