![]() |
|
|||
File indexing completed on 2025-02-22 10:59:17
0001 #ifndef __XRD_POLL_H__ 0002 #define __XRD_POLL_H__ 0003 /******************************************************************************/ 0004 /* */ 0005 /* X r d P o l l . h h */ 0006 /* */ 0007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 0008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 0009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 0010 /* */ 0011 /* This file is part of the XRootD software suite. */ 0012 /* */ 0013 /* XRootD is free software: you can redistribute it and/or modify it under */ 0014 /* the terms of the GNU Lesser General Public License as published by the */ 0015 /* Free Software Foundation, either version 3 of the License, or (at your */ 0016 /* option) any later version. */ 0017 /* */ 0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 0020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 0021 /* License for more details. */ 0022 /* */ 0023 /* You should have received a copy of the GNU Lesser General Public License */ 0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 0025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 0026 /* */ 0027 /* The copyright holder's institutional names and contributor's names may not */ 0028 /* be used to endorse or promote products derived from this software without */ 0029 /* specific prior written permission of the institution or contributor. */ 0030 /******************************************************************************/ 0031 0032 #include <poll.h> 0033 #include "XrdSys/XrdSysPthread.hh" 0034 0035 #define XRD_NUMPOLLERS 3 0036 0037 class XrdPollInfo; 0038 class XrdSysSemaphore; 0039 0040 class XrdPoll 0041 { 0042 public: 0043 0044 // Attach() is called when a new link needs to be assigned to a poller 0045 // 0046 static int Attach(XrdPollInfo &pInfo); 0047 0048 // Detach() is called when a link is being discarded 0049 // 0050 static void Detach(XrdPollInfo &pInfo); 0051 0052 // Disable() is called when we need to mask interrupts from a link 0053 // 0054 virtual void Disable(XrdPollInfo &pInfo, const char *etxt=0) = 0; 0055 0056 // Enable() is called when we want to receive interrupts from a link 0057 // 0058 virtual int Enable(XrdPollInfo &pInfo) = 0; 0059 0060 // Finish() is called to allow a link to gracefully terminate when scheduled 0061 // 0062 static int Finish(XrdPollInfo &pInfo, const char *etxt=0); //Implementation supplied 0063 0064 // Poll2Text() converts bits in an revents item to text 0065 // 0066 static char *Poll2Text(short events); // Implementation supplied 0067 0068 // Setup() is called at config time to perform poller configuration 0069 // 0070 static int Setup(int numfd); // Implementation supplied 0071 0072 // Start() is called via a thread for each poller that was created 0073 // 0074 virtual void Start(XrdSysSemaphore *syncp, int &rc) = 0; 0075 0076 // Stats() is called to provide statistics on polling 0077 // 0078 static int Stats(char *buff, int blen, int do_sync=0); 0079 0080 // Identification of the thread handling this object 0081 // 0082 int PID; // Poller ID 0083 pthread_t TID; // Thread ID 0084 0085 // The following table reference the pollers in effect 0086 // 0087 static XrdPoll *Pollers[XRD_NUMPOLLERS]; 0088 0089 XrdPoll(); 0090 virtual ~XrdPoll() {} 0091 0092 protected: 0093 0094 static const char *TraceID; // For tracing 0095 0096 // Gets the next request on the poll pipe. This is common to all implentations. 0097 // 0098 int getRequest(); // Implementation supplied 0099 0100 // Exclude() called to exclude a link from a poll set 0101 // 0102 virtual void Exclude(XrdPollInfo &pInfo) = 0; 0103 0104 // Include() called to include a link in a poll set 0105 // 0106 virtual int Include(XrdPollInfo &pInfo) = 0; 0107 0108 // newPoller() called to get a new poll object at initialization time 0109 // Even though static, an implementation must be supplied. 0110 // 0111 static XrdPoll *newPoller(int pollid, int numfd) /* = 0 */; 0112 0113 // The following is common to all implementations 0114 // 0115 XrdSysMutex PollPipe; 0116 struct pollfd PipePoll; 0117 int CmdFD; // FD to send PipeData commands 0118 int ReqFD; // FD to recv PipeData requests 0119 struct PipeData {union {XrdSysSemaphore *theSem; 0120 struct {int fd; 0121 int ent;} Arg; 0122 } Parms; 0123 enum cmd {EnFD, DiFD, RmFD, Post}; 0124 cmd req; 0125 }; 0126 PipeData ReqBuff; 0127 char *PipeBuff; 0128 int PipeBlen; 0129 0130 // The following are statistical counters each implementation must maintain 0131 // 0132 int numEnabled; // Count of Enable() calls 0133 int numEvents; // Count of poll fd's dispatched 0134 int numInterrupts; // Number of interrupts (e.g., signals) 0135 0136 private: 0137 0138 static XrdSysMutex doingAttach; 0139 int numAttached; // Number of fd's attached to poller 0140 }; 0141 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |