|
CPN
Computational Process Networks
|
A convenience handle for event loops so that one can interrupt a Poll before it times out. More...
#include <WakeupHandle.h>
Inheritance diagram for WakeupHandle:
Collaboration diagram for WakeupHandle:Public Types | |
| typedef AutoLock< PthreadMutex > | ALock |
Public Member Functions | |
| WakeupHandle () | |
| virtual | ~WakeupHandle () |
| void | SendWakeup () |
| Causes this handler to become readable any Poll on this FileHandler will then return. More... | |
| void | Read () |
| Read until not readable anymore. More... | |
| int | Poll (double timeout) |
| bool | Readable (bool r) |
| Set that the file is currently readable or not. More... | |
| bool | Readable () const |
| Gives the current readability status of the file. More... | |
| bool | Writeable (bool w) |
| Set that this file is currently writeable or not. More... | |
| bool | Writeable () const |
| Gives the current writability status of the file. More... | |
| int | FD () const |
| int | FD (int filed) |
| Set the current file descriptor. More... | |
| bool | Eof () const |
| bool | Eof (bool e) |
| Set/reset the end of file condition. More... | |
| bool | Good () const |
| Convenience method for testing if the file this FileHandle has is open and not at end of file. More... | |
| bool | Closed () const |
| void | SetBlocking (bool blocking) |
| Manipulate how the current file handles blocking. More... | |
| bool | IsBlocking () const |
| Test if the current file is in blocking or non blocking mode. More... | |
| void | Reset () |
| Clear all internal state including the file descriptor! WARNING does not close the file! More... | |
| void | Close () |
| Close the file and reset the internal state. More... | |
| unsigned | Read (void *ptr, unsigned len) |
| Read data from the file descriptor. More... | |
| unsigned | Readv (const iovec *iov, int iovcnt) |
| scatter gather io version of Read More... | |
| unsigned | Write (const void *ptr, unsigned len) |
| Write data to the file descriptor. More... | |
| unsigned | Writev (const iovec *iov, int iovcnt) |
| scatter gather io version of Write More... | |
| void | Flush () |
| Tell the OS to flush any buffers it has. May not be supported for all file types. More... | |
Static Public Member Functions | |
| static int | Poll (IteratorRef< FileHandle * > begin, IteratorRef< FileHandle * > end, double timeout) |
| poll a list of FileHandles for any activity and call the appropriate On method. More... | |
| static void | SetBlocking (int fd, bool blocking) |
| a convenience method that allows one to set the same blocking parameters for a file descriptor without setting it inside a FileHandle. More... | |
| static bool | IsBlocking (int fd) |
| Test the given file descriptor if it is in blocking mode. More... | |
Protected Member Functions | |
| virtual void | OnWriteable () |
| Called by Poll when it detects that the file is writeable. More... | |
Protected Attributes | |
| PthreadMutex | file_lock |
| int | fd |
| bool | readable |
| bool | writeable |
| bool | eof |
Private Member Functions | |
| void | OnReadable () |
| Called by Poll when it detects that the file is readable. More... | |
Private Attributes | |
| int | wfd |
A convenience handle for event loops so that one can interrupt a Poll before it times out.
SendWakeup my be called from any thread.
Definition at line 35 of file WakeupHandle.h.
|
inherited |
Definition at line 43 of file FileHandle.h.
| WakeupHandle::WakeupHandle | ( | ) |
Definition at line 30 of file WakeupHandle.cc.
References FileHandle::FD(), FileHandle::Readable(), FileHandle::SetBlocking(), wfd, and FileHandle::Writeable().
Here is the call graph for this function:
|
virtual |
Definition at line 45 of file WakeupHandle.cc.
References wfd.
|
inherited |
Close the file and reset the internal state.
Definition at line 146 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::readable, and FileHandle::writeable.
Referenced by CPN::ConnectionServer::Close(), CPN::RemoteContext::EntryPoint(), CPN::RemoteQueue::HandleError(), CPN::RemoteQueue::InternalCheckStatus(), and CPN::RemoteContextDaemon::Terminate().
Here is the caller graph for this function:
|
inlineinherited |
Definition at line 128 of file FileHandle.h.
References FileHandle::fd, and FileHandle::file_lock.
Referenced by SocketHandle::Connect(), CPN::ConnectionServer::ConnectReader(), CPN::ConnectionServer::ConnectWriter(), CPN::RemoteQueue::FileThreadEntryPoint(), CPN::RemoteQueue::InternalCheckStatus(), CPN::RemoteQueue::LogState(), CPN::ConnectionServer::LogState(), CPN::RemoteContextDaemon::Run(), CPN::RemoteContextDaemon::Client::Send(), and CPN::RemoteContext::SendMessage().
Here is the caller graph for this function:
|
inlineinherited |
Definition at line 115 of file FileHandle.h.
References FileHandle::eof, and FileHandle::file_lock.
Referenced by CPN::RemoteQueue::EnqueuePacket(), CPN::RemoteContext::EntryPoint(), CPN::RemoteQueue::InternalCheckStatus(), CPN::RemoteContextDaemon::Client::Read(), and CPN::RemoteQueue::Read().
Here is the caller graph for this function:Set/reset the end of file condition.
| e | the new end of file condition |
Definition at line 120 of file FileHandle.h.
References FileHandle::eof, and FileHandle::file_lock.
|
inlineinherited |
Definition at line 106 of file FileHandle.h.
References FileHandle::fd, and FileHandle::file_lock.
Referenced by ServerSocketHandle::Accept(), CPN::RemoteContextDaemon::Client::Client(), SocketHandle::Connect(), CPN::ConnectionServer::ConnectWriter(), SocketHandle::CreatePair(), CPN::RemoteQueue::FileThreadEntryPoint(), FileHandle::Flush(), CPN::ConnectionServer::GetAddress(), SocketHandle::GetKeepAlive(), SocketHandle::GetLingerTimeout(), SocketHandle::GetNoDelay(), SocketHandle::GetPendingError(), SocketHandle::GetReceiveBufferSize(), SocketHandle::GetReceiveTimeout(), SocketHandle::GetSendBufferSize(), SocketHandle::GetSendTimeout(), FileHandle::IsBlocking(), ServerSocketHandle::Listen(), FileHandle::Poll(), CPN::RemoteContextDaemon::Run(), FileHandle::SetBlocking(), SocketHandle::SetKeepAlive(), SocketHandle::SetLingerTimeout(), SocketHandle::SetNoDelay(), SocketHandle::SetReceiveBufferSize(), SocketHandle::SetReceiveTimeout(), SocketHandle::SetSendBufferSize(), SocketHandle::SetSendTimeout(), SocketHandle::ShutdownRead(), SocketHandle::ShutdownWrite(), and WakeupHandle().
Here is the caller graph for this function:Set the current file descriptor.
| filed | the new file descriptor |
Definition at line 111 of file FileHandle.h.
References FileHandle::fd, and FileHandle::file_lock.
|
inherited |
Tell the OS to flush any buffers it has. May not be supported for all file types.
Definition at line 293 of file FileHandle.cc.
References FileHandle::FD().
Here is the call graph for this function:
|
inlineinherited |
Convenience method for testing if the file this FileHandle has is open and not at end of file.
Definition at line 125 of file FileHandle.h.
References FileHandle::eof, FileHandle::fd, and FileHandle::file_lock.
Referenced by CPN::RemoteContext::EntryPoint(), and CPN::RemoteContextDaemon::Client::Read().
Here is the caller graph for this function:
|
inherited |
Test if the current file is in blocking or non blocking mode.
Definition at line 128 of file FileHandle.cc.
References FileHandle::FD().
Here is the call graph for this function:Test the given file descriptor if it is in blocking mode.
| fd | the file descriptor to test |
Definition at line 132 of file FileHandle.cc.
|
inlineprivatevirtual |
Called by Poll when it detects that the file is readable.
Reimplemented from FileHandle.
Definition at line 50 of file WakeupHandle.h.
|
inlineprotectedvirtualinherited |
Called by Poll when it detects that the file is writeable.
Definition at line 212 of file FileHandle.h.
References FileHandle::Writeable().
Referenced by FileHandle::Poll().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticinherited |
poll a list of FileHandles for any activity and call the appropriate On method.
Definition at line 34 of file FileHandle.cc.
References FileHandle::FD(), FileHandle::fd, FileHandle::OnReadable(), FileHandle::OnWriteable(), FileHandle::Readable(), and FileHandle::Writeable().
Referenced by CPN::RemoteContext::EntryPoint(), CPN::RemoteQueue::FileThreadEntryPoint(), CPN::ConnectionServer::Poll(), FileHandle::Poll(), and CPN::RemoteContextDaemon::Run().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inherited |
Poll the current file descriptor for activity specified by the current readable or writeable status, if false poll that value, and call one of OnWriteable or OnReadable whos default action is to set Readable or Writeable to true.
| timeout | -1 to wait forever for activity 0 to poll and return immediately or a time to wait in seconds. |
Definition at line 106 of file FileHandle.cc.
References FileHandle::Poll().
Here is the call graph for this function:| void WakeupHandle::Read | ( | ) |
Read until not readable anymore.
Definition at line 70 of file WakeupHandle.cc.
References FileHandle::Read().
Referenced by CPN::ConnectionServer::Poll().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inherited |
Read data from the file descriptor.
Will set the end of file condition if read detects end of file.
| ptr | pointer to write data to |
| len | the maximum number of bytes to write to ptr |
Definition at line 159 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::Readable(), and FileHandle::readable.
Referenced by CPN::RemoteQueue::D4RTagPacket(), and Read().
Here is the call graph for this function:
Here is the caller graph for this function:Set that the file is currently readable or not.
| r | true or false |
Definition at line 86 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::readable.
Referenced by CPN::RemoteContext::EntryPoint(), FileHandle::Poll(), CPN::ConnectionServer::Poll(), and CPN::RemoteQueue::Read().
Here is the caller graph for this function:
|
inlineinherited |
Gives the current readability status of the file.
Definition at line 91 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::readable.
Referenced by ServerSocketHandle::Accept(), CPN::RemoteContextDaemon::Client::Client(), FileHandle::OnReadable(), CPN::RemoteContextDaemon::Read(), FileHandle::Read(), FileHandle::Readv(), SocketHandle::Recv(), CPN::RemoteContextDaemon::Run(), and WakeupHandle().
Here is the caller graph for this function:
|
inherited |
scatter gather io version of Read
Definition at line 190 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::Readable(), and FileHandle::readable.
Referenced by CPN::RemoteQueue::EnqueuePacket().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inherited |
Clear all internal state including the file descriptor! WARNING does not close the file!
Definition at line 138 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::readable, and FileHandle::writeable.
Referenced by CPN::ConnectionServer::ConnectWriter(), CPN::RemoteQueue::FileThreadEntryPoint(), and FileHandle::~FileHandle().
Here is the caller graph for this function:| void WakeupHandle::SendWakeup | ( | ) |
Causes this handler to become readable any Poll on this FileHandler will then return.
Definition at line 50 of file WakeupHandle.cc.
References FileHandle::file_lock, and wfd.
Referenced by CPN::RemoteQueueHolder::Shutdown().
Here is the caller graph for this function:
|
inherited |
Manipulate how the current file handles blocking.
| blocking | true to set to blocking mode (default) false to set to non blocking mode. |
In non blocking mode all reads and writes will not block. Use Poll to block.
Definition at line 111 of file FileHandle.cc.
References FileHandle::FD().
Referenced by WakeupHandle().
Here is the call graph for this function:
Here is the caller graph for this function:a convenience method that allows one to set the same blocking parameters for a file descriptor without setting it inside a FileHandle.
| fd | the file descriptor |
| blocking | true or false see SetBlock |
Definition at line 115 of file FileHandle.cc.
|
inherited |
Write data to the file descriptor.
| ptr | pointer to beginning of data to write |
| len | length of data to write |
Definition at line 225 of file FileHandle.cc.
References FileHandle::fd, FileHandle::file_lock, and FileHandle::Writeable().
Referenced by CPN::ConnectionServer::ConnectWriter(), CPN::RemoteContextDaemon::Client::Send(), CPN::RemoteContext::SendMessage(), and CPN::RemoteQueue::WriteBytes().
Here is the call graph for this function:
Here is the caller graph for this function:Set that this file is currently writeable or not.
| w | true or false |
Definition at line 97 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::writeable.
Referenced by FileHandle::Poll().
Here is the caller graph for this function:
|
inlineinherited |
Gives the current writability status of the file.
Definition at line 102 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::writeable.
Referenced by FileHandle::OnWriteable(), SocketHandle::Send(), WakeupHandle(), FileHandle::Write(), and FileHandle::Writev().
Here is the caller graph for this function:
|
inherited |
scatter gather io version of Write
Definition at line 261 of file FileHandle.cc.
References FileHandle::fd, FileHandle::file_lock, and FileHandle::Writeable().
Referenced by CPN::RemoteQueue::WriteBytes().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protectedinherited |
Definition at line 217 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Eof(), FileHandle::Good(), FileHandle::Read(), FileHandle::Readv(), SocketHandle::Recv(), and FileHandle::Reset().
|
protectedinherited |
Definition at line 214 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Closed(), FileHandle::FD(), FileHandle::Good(), FileHandle::Poll(), FileHandle::Read(), FileHandle::Readv(), SocketHandle::Recv(), FileHandle::Reset(), SocketHandle::Send(), FileHandle::Write(), FileHandle::Writev(), and FileHandle::~FileHandle().
|
mutableprotectedinherited |
Definition at line 213 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Closed(), FileHandle::Eof(), FileHandle::FD(), FileHandle::Good(), FileHandle::Read(), FileHandle::Readable(), FileHandle::Readv(), SocketHandle::Recv(), FileHandle::Reset(), SocketHandle::Send(), SendWakeup(), FileHandle::Write(), FileHandle::Writeable(), and FileHandle::Writev().
|
protectedinherited |
Definition at line 215 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Read(), FileHandle::Readable(), FileHandle::Readv(), SocketHandle::Recv(), and FileHandle::Reset().
|
private |
Definition at line 51 of file WakeupHandle.h.
Referenced by SendWakeup(), WakeupHandle(), and ~WakeupHandle().
|
protectedinherited |
Definition at line 216 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Reset(), and FileHandle::Writeable().
1.8.5