Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
|
#include <vsnet_socketset.h>
Public Member Functions | |
SocketSet (bool blockmainthread=false) | |
~SocketSet () | |
bool | addDownloadManager (boost::shared_ptr< VsnetDownload::Client::Manager >mgr) |
bool | addDownloadManager (boost::shared_ptr< VsnetDownload::Server::Manager >mgr) |
void | set (VsnetSocketBase *s) |
void | unset (VsnetSocketBase *s) |
The upper thread takes a socket out of the _autoset. More... | |
int | wait (timeval *tv=NULL) |
The upper thread waits for something to arrive on the socket. More... | |
void | add_pending (int fd) |
void | rem_pending (int fd) |
void | waste_time (long sec, long usec) |
unthreaded case More... | |
virtual void | run () |
void | wakeup () |
void | predestroy () |
only call predestroy if you know the whole set will be destructed soonish–clears the autoset More... | |
![]() | |
VSThread (bool detached) | |
virtual | ~VSThread () |
void | start () |
void | join () |
Additional Inherited Members | |
![]() | |
static void | init () |
global initialization function for the thread subsystem More... | |
Definition at line 56 of file vsnet_socketset.h.
SocketSet::SocketSet | ( | bool | blockmainthread = false ) |
Definition at line 12 of file vsnet_socketset.cpp.
SocketSet::~SocketSet | ( | ) |
Definition at line 23 of file vsnet_socketset.cpp.
References VSMutex::lock(), VSMutex::unlock(), and VSCond::wait().
void SocketSet::add_pending | ( | int | fd) |
Definition at line 120 of file vsnet_socketset.cpp.
References VSMutex::lock(), and VSMutex::unlock().
Referenced by VsnetTCPSocket::inner_complete_a_packet(), VsnetUDPSocket::lower_selected(), VsnetTCPSocket::lower_selected(), and ServerSocketTCP::lower_selected().
bool SocketSet::addDownloadManager | ( | boost::shared_ptr< VsnetDownload::Client::Manager > | mgr) |
Definition at line 39 of file vsnet_socketset.cpp.
Referenced by NetClient::NetClient().
bool SocketSet::addDownloadManager | ( | boost::shared_ptr< VsnetDownload::Server::Manager > | mgr) |
Definition at line 46 of file vsnet_socketset.cpp.
void SocketSet::predestroy | ( | ) |
only call predestroy if you know the whole set will be destructed soonish–clears the autoset
Definition at line 35 of file vsnet_socketset.cpp.
void SocketSet::rem_pending | ( | int | fd) |
Definition at line 130 of file vsnet_socketset.cpp.
References VSMutex::lock(), and VSMutex::unlock().
Referenced by ServerSocketTCP::acceptNewConn(), VsnetTCPSocket::isActive(), VsnetUDPSocket::recvbuf(), and VsnetTCPSocket::recvbuf().
|
virtual |
Implements VSThread.
Definition at line 315 of file vsnet_socketset.cpp.
References VSMutex::lock(), VSCond::signal(), and VSMutex::unlock().
void SocketSet::set | ( | VsnetSocketBase * | s) |
Once a socket is registered using this function, setRead is automatically called for it before each select
Definition at line 53 of file vsnet_socketset.cpp.
Referenced by SOCKETALT::addToSet(), VsnetSocketBase::setSet(), and VsnetSocketBase::VsnetSocketBase().
void SocketSet::unset | ( | VsnetSocketBase * | s) |
The upper thread takes a socket out of the _autoset.
Definition at line 59 of file vsnet_socketset.cpp.
Referenced by VsnetSocketBase::disconnect(), VsnetSocketBase::setSet(), and VsnetSocketBase::~VsnetSocketBase().
int SocketSet::wait | ( | timeval * | tv = NULL ) |
The upper thread waits for something to arrive on the socket.
Definition at line 67 of file vsnet_socketset.cpp.
Referenced by AccountServer::start().
void SocketSet::wakeup | ( | ) |
Definition at line 279 of file vsnet_socketset.cpp.
Referenced by VsnetDownload::Server::Manager::addCmdDownload(), VsnetDownload::Client::Manager::addItems(), and VsnetTCPSocket::sendbuf().
void SocketSet::waste_time | ( | long | sec, |
long | usec | ||
) |
unthreaded case
Use this function liberally in you code. If you don't have a network thread, it will check select and return. If you have a place in your code where you want to wait anyway, replace your waiting function with a call to this function.
Definition at line 290 of file vsnet_socketset.cpp.
Referenced by NetClient::loginAcctLoop(), and VsnetTCPSocket::private_nothread_conditional_write().