mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-27 22:32:02 +08:00
removed exception specifications. thread exceptions weren't
being listed and they'd have to be added to every one. just doesn't seem worth the trouble.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
// CNetworkAddress
|
||||
//
|
||||
|
||||
CNetworkAddress::CNetworkAddress(UInt16 port) throw(XSocketAddress)
|
||||
CNetworkAddress::CNetworkAddress(UInt16 port)
|
||||
{
|
||||
if (port == 0)
|
||||
throw XSocketAddress(XSocketAddress::kBadPort, CString(), port);
|
||||
@@ -21,7 +21,6 @@ CNetworkAddress::CNetworkAddress(UInt16 port) throw(XSocketAddress)
|
||||
}
|
||||
|
||||
CNetworkAddress::CNetworkAddress(const CString& hostname, UInt16 port)
|
||||
throw(XSocketAddress)
|
||||
{
|
||||
if (port == 0)
|
||||
throw XSocketAddress(XSocketAddress::kBadPort, hostname, port);
|
||||
@@ -54,12 +53,12 @@ CNetworkAddress::~CNetworkAddress()
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const struct sockaddr* CNetworkAddress::getAddress() const throw()
|
||||
const struct sockaddr* CNetworkAddress::getAddress() const
|
||||
{
|
||||
return &m_address;
|
||||
}
|
||||
|
||||
int CNetworkAddress::getAddressLength() const throw()
|
||||
int CNetworkAddress::getAddressLength() const
|
||||
{
|
||||
return sizeof(m_address);
|
||||
}
|
||||
|
||||
@@ -9,16 +9,16 @@ class CString;
|
||||
|
||||
class CNetworkAddress {
|
||||
public:
|
||||
CNetworkAddress(UInt16 port) throw(XSocketAddress);
|
||||
CNetworkAddress(const CString& hostname, UInt16 port) throw(XSocketAddress);
|
||||
CNetworkAddress(UInt16 port);
|
||||
CNetworkAddress(const CString& hostname, UInt16 port);
|
||||
~CNetworkAddress();
|
||||
|
||||
// manipulators
|
||||
|
||||
// accessors
|
||||
|
||||
const struct sockaddr* getAddress() const throw();
|
||||
int getAddressLength() const throw();
|
||||
const struct sockaddr* getAddress() const;
|
||||
int getAddressLength() const;
|
||||
|
||||
private:
|
||||
struct sockaddr m_address;
|
||||
|
||||
@@ -27,7 +27,7 @@ CSocketInputStream::~CSocketInputStream()
|
||||
}
|
||||
|
||||
void CSocketInputStream::write(
|
||||
const void* data, UInt32 n) throw()
|
||||
const void* data, UInt32 n)
|
||||
{
|
||||
if (!m_hungup && n > 0) {
|
||||
m_buffer.write(data, n);
|
||||
@@ -36,13 +36,13 @@ void CSocketInputStream::write(
|
||||
}
|
||||
}
|
||||
|
||||
void CSocketInputStream::hangup() throw()
|
||||
void CSocketInputStream::hangup()
|
||||
{
|
||||
m_hungup = true;
|
||||
m_empty.broadcast();
|
||||
}
|
||||
|
||||
void CSocketInputStream::close() throw(XIO)
|
||||
void CSocketInputStream::close()
|
||||
{
|
||||
CLock lock(m_mutex);
|
||||
if (m_closed) {
|
||||
@@ -56,7 +56,7 @@ void CSocketInputStream::close() throw(XIO)
|
||||
}
|
||||
|
||||
UInt32 CSocketInputStream::read(
|
||||
void* dst, UInt32 n) throw(XIO)
|
||||
void* dst, UInt32 n)
|
||||
{
|
||||
CLock lock(m_mutex);
|
||||
if (m_closed) {
|
||||
@@ -86,7 +86,7 @@ UInt32 CSocketInputStream::read(
|
||||
return n;
|
||||
}
|
||||
|
||||
UInt32 CSocketInputStream::getSize() const throw()
|
||||
UInt32 CSocketInputStream::getSize() const
|
||||
{
|
||||
CLock lock(m_mutex);
|
||||
return m_buffer.getSize();
|
||||
|
||||
@@ -16,19 +16,19 @@ class CSocketInputStream : public IInputStream {
|
||||
// manipulators
|
||||
|
||||
// write() appends n bytes to the buffer
|
||||
void write(const void*, UInt32 n) throw();
|
||||
void write(const void*, UInt32 n);
|
||||
|
||||
// causes read() to always return immediately. if there is no
|
||||
// more data then it returns 0. further writes are discarded.
|
||||
void hangup() throw();
|
||||
void hangup();
|
||||
|
||||
// accessors
|
||||
|
||||
// IInputStream overrides
|
||||
// these all lock the mutex for their duration
|
||||
virtual void close() throw(XIO);
|
||||
virtual UInt32 read(void*, UInt32 count) throw(XIO);
|
||||
virtual UInt32 getSize() const throw();
|
||||
virtual void close();
|
||||
virtual UInt32 read(void*, UInt32 count);
|
||||
virtual UInt32 getSize() const;
|
||||
|
||||
private:
|
||||
CMutex* m_mutex;
|
||||
|
||||
@@ -23,22 +23,22 @@ CSocketOutputStream::~CSocketOutputStream()
|
||||
delete m_closeCB;
|
||||
}
|
||||
|
||||
const void* CSocketOutputStream::peek(UInt32 n) throw()
|
||||
const void* CSocketOutputStream::peek(UInt32 n)
|
||||
{
|
||||
return m_buffer.peek(n);
|
||||
}
|
||||
|
||||
void CSocketOutputStream::pop(UInt32 n) throw()
|
||||
void CSocketOutputStream::pop(UInt32 n)
|
||||
{
|
||||
m_buffer.pop(n);
|
||||
}
|
||||
|
||||
UInt32 CSocketOutputStream::getSize() const throw()
|
||||
UInt32 CSocketOutputStream::getSize() const
|
||||
{
|
||||
return m_buffer.getSize();
|
||||
}
|
||||
|
||||
void CSocketOutputStream::close() throw(XIO)
|
||||
void CSocketOutputStream::close()
|
||||
{
|
||||
CLock lock(m_mutex);
|
||||
if (m_closed) {
|
||||
@@ -52,7 +52,7 @@ void CSocketOutputStream::close() throw(XIO)
|
||||
}
|
||||
|
||||
UInt32 CSocketOutputStream::write(
|
||||
const void* data, UInt32 n) throw(XIO)
|
||||
const void* data, UInt32 n)
|
||||
{
|
||||
CLock lock(m_mutex);
|
||||
if (m_closed) {
|
||||
@@ -63,7 +63,7 @@ UInt32 CSocketOutputStream::write(
|
||||
return n;
|
||||
}
|
||||
|
||||
void CSocketOutputStream::flush() throw(XIO)
|
||||
void CSocketOutputStream::flush()
|
||||
{
|
||||
// wait until all data is written
|
||||
while (getSizeWithLock() > 0) {
|
||||
@@ -71,7 +71,7 @@ void CSocketOutputStream::flush() throw(XIO)
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 CSocketOutputStream::getSizeWithLock() const throw()
|
||||
UInt32 CSocketOutputStream::getSizeWithLock() const
|
||||
{
|
||||
CLock lock(m_mutex);
|
||||
return m_buffer.getSize();
|
||||
|
||||
@@ -16,22 +16,22 @@ class CSocketOutputStream : public IOutputStream {
|
||||
|
||||
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
||||
// pop() discards the next n bytes.
|
||||
const void* peek(UInt32 n) throw();
|
||||
void pop(UInt32 n) throw();
|
||||
const void* peek(UInt32 n);
|
||||
void pop(UInt32 n);
|
||||
|
||||
// accessors
|
||||
|
||||
// return the number of bytes in the buffer
|
||||
UInt32 getSize() const throw();
|
||||
UInt32 getSize() const;
|
||||
|
||||
// IOutputStream overrides
|
||||
// these all lock the mutex for their duration
|
||||
virtual void close() throw(XIO);
|
||||
virtual UInt32 write(const void*, UInt32 count) throw(XIO);
|
||||
virtual void flush() throw(XIO);
|
||||
virtual void close();
|
||||
virtual UInt32 write(const void*, UInt32 count);
|
||||
virtual void flush();
|
||||
|
||||
private:
|
||||
UInt32 getSizeWithLock() const throw();
|
||||
UInt32 getSizeWithLock() const;
|
||||
|
||||
private:
|
||||
CMutex* m_mutex;
|
||||
|
||||
@@ -17,7 +17,7 @@ CSocketStreamBuffer::~CSocketStreamBuffer()
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const void* CSocketStreamBuffer::peek(UInt32 n) throw()
|
||||
const void* CSocketStreamBuffer::peek(UInt32 n)
|
||||
{
|
||||
assert(n <= m_size);
|
||||
|
||||
@@ -36,7 +36,7 @@ const void* CSocketStreamBuffer::peek(UInt32 n) throw()
|
||||
return reinterpret_cast<const void*>(head->begin());
|
||||
}
|
||||
|
||||
void CSocketStreamBuffer::pop(UInt32 n) throw()
|
||||
void CSocketStreamBuffer::pop(UInt32 n)
|
||||
{
|
||||
m_size -= n;
|
||||
|
||||
@@ -58,7 +58,7 @@ void CSocketStreamBuffer::pop(UInt32 n) throw()
|
||||
}
|
||||
|
||||
void CSocketStreamBuffer::write(
|
||||
const void* vdata, UInt32 n) throw()
|
||||
const void* vdata, UInt32 n)
|
||||
{
|
||||
assert(vdata != NULL);
|
||||
|
||||
@@ -100,7 +100,7 @@ void CSocketStreamBuffer::write(
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 CSocketStreamBuffer::getSize() const throw()
|
||||
UInt32 CSocketStreamBuffer::getSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
@@ -14,16 +14,16 @@ class CSocketStreamBuffer {
|
||||
|
||||
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
||||
// pop() discards the next n bytes.
|
||||
const void* peek(UInt32 n) throw();
|
||||
void pop(UInt32 n) throw();
|
||||
const void* peek(UInt32 n);
|
||||
void pop(UInt32 n);
|
||||
|
||||
// write() appends n bytes to the buffer
|
||||
void write(const void*, UInt32 n) throw();
|
||||
void write(const void*, UInt32 n);
|
||||
|
||||
// accessors
|
||||
|
||||
// return the number of bytes in the buffer
|
||||
UInt32 getSize() const throw();
|
||||
UInt32 getSize() const;
|
||||
|
||||
private:
|
||||
static const UInt32 kChunkSize;
|
||||
|
||||
@@ -31,7 +31,7 @@ CTCPListenSocket::~CTCPListenSocket()
|
||||
}
|
||||
|
||||
void CTCPListenSocket::bind(
|
||||
const CNetworkAddress& addr) throw(XSocket)
|
||||
const CNetworkAddress& addr)
|
||||
{
|
||||
if (::bind(m_fd, addr.getAddress(), addr.getAddressLength()) == -1) {
|
||||
if (errno == EADDRINUSE) {
|
||||
@@ -44,7 +44,7 @@ void CTCPListenSocket::bind(
|
||||
}
|
||||
}
|
||||
|
||||
ISocket* CTCPListenSocket::accept() throw(XSocket)
|
||||
ISocket* CTCPListenSocket::accept()
|
||||
{
|
||||
for (;;) {
|
||||
struct sockaddr addr;
|
||||
@@ -60,7 +60,7 @@ ISocket* CTCPListenSocket::accept() throw(XSocket)
|
||||
}
|
||||
}
|
||||
|
||||
void CTCPListenSocket::close() throw(XIO)
|
||||
void CTCPListenSocket::close()
|
||||
{
|
||||
if (m_fd == -1) {
|
||||
throw XIOClosed();
|
||||
|
||||
@@ -13,9 +13,9 @@ class CTCPListenSocket : public IListenSocket {
|
||||
// accessors
|
||||
|
||||
// IListenSocket overrides
|
||||
virtual void bind(const CNetworkAddress&) throw(XSocket);
|
||||
virtual ISocket* accept() throw(XSocket);
|
||||
virtual void close() throw(XIO);
|
||||
virtual void bind(const CNetworkAddress&);
|
||||
virtual ISocket* accept();
|
||||
virtual void close();
|
||||
|
||||
private:
|
||||
int m_fd;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
// CTCPSocket
|
||||
//
|
||||
|
||||
CTCPSocket::CTCPSocket() throw(XSocket)
|
||||
CTCPSocket::CTCPSocket()
|
||||
{
|
||||
m_fd = socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (m_fd == -1) {
|
||||
@@ -29,7 +29,7 @@ CTCPSocket::CTCPSocket() throw(XSocket)
|
||||
init();
|
||||
}
|
||||
|
||||
CTCPSocket::CTCPSocket(int fd) throw() :
|
||||
CTCPSocket::CTCPSocket(int fd) :
|
||||
m_fd(fd)
|
||||
{
|
||||
assert(m_fd != -1);
|
||||
@@ -60,7 +60,6 @@ CTCPSocket::~CTCPSocket()
|
||||
}
|
||||
|
||||
void CTCPSocket::bind(const CNetworkAddress& addr)
|
||||
throw(XSocket)
|
||||
{
|
||||
if (::bind(m_fd, addr.getAddress(), addr.getAddressLength()) == -1) {
|
||||
if (errno == EADDRINUSE) {
|
||||
@@ -71,7 +70,6 @@ void CTCPSocket::bind(const CNetworkAddress& addr)
|
||||
}
|
||||
|
||||
void CTCPSocket::connect(const CNetworkAddress& addr)
|
||||
throw(XSocket)
|
||||
{
|
||||
CThread::testCancel();
|
||||
if (::connect(m_fd, addr.getAddress(), addr.getAddressLength()) == -1) {
|
||||
@@ -85,7 +83,7 @@ void CTCPSocket::connect(const CNetworkAddress& addr)
|
||||
this, &CTCPSocket::service));
|
||||
}
|
||||
|
||||
void CTCPSocket::close() throw(XIO)
|
||||
void CTCPSocket::close()
|
||||
{
|
||||
// shutdown I/O thread before close
|
||||
if (m_thread != NULL) {
|
||||
@@ -114,17 +112,17 @@ void CTCPSocket::close() throw(XIO)
|
||||
}
|
||||
}
|
||||
|
||||
IInputStream* CTCPSocket::getInputStream() throw()
|
||||
IInputStream* CTCPSocket::getInputStream()
|
||||
{
|
||||
return m_input;
|
||||
}
|
||||
|
||||
IOutputStream* CTCPSocket::getOutputStream() throw()
|
||||
IOutputStream* CTCPSocket::getOutputStream()
|
||||
{
|
||||
return m_output;
|
||||
}
|
||||
|
||||
void CTCPSocket::init() throw(XIO)
|
||||
void CTCPSocket::init()
|
||||
{
|
||||
m_mutex = new CMutex;
|
||||
m_thread = NULL;
|
||||
@@ -137,7 +135,7 @@ void CTCPSocket::init() throw(XIO)
|
||||
this, &CTCPSocket::closeOutput));
|
||||
}
|
||||
|
||||
void CTCPSocket::service(void*) throw(XThread)
|
||||
void CTCPSocket::service(void*)
|
||||
{
|
||||
assert(m_fd != -1);
|
||||
|
||||
@@ -211,14 +209,14 @@ void CTCPSocket::service(void*) throw(XThread)
|
||||
}
|
||||
}
|
||||
|
||||
void CTCPSocket::closeInput(void*) throw()
|
||||
void CTCPSocket::closeInput(void*)
|
||||
{
|
||||
// note -- m_mutex should already be locked
|
||||
shutdown(m_fd, 0);
|
||||
m_connected &= ~kRead;
|
||||
}
|
||||
|
||||
void CTCPSocket::closeOutput(void*) throw()
|
||||
void CTCPSocket::closeOutput(void*)
|
||||
{
|
||||
// note -- m_mutex should already be locked
|
||||
shutdown(m_fd, 1);
|
||||
|
||||
@@ -13,8 +13,8 @@ class CBufferedOutputStream;
|
||||
|
||||
class CTCPSocket : public ISocket {
|
||||
public:
|
||||
CTCPSocket() throw(XSocket);
|
||||
CTCPSocket(int fd) throw();
|
||||
CTCPSocket();
|
||||
CTCPSocket(int fd);
|
||||
~CTCPSocket();
|
||||
|
||||
// manipulators
|
||||
@@ -22,17 +22,17 @@ class CTCPSocket : public ISocket {
|
||||
// accessors
|
||||
|
||||
// ISocket overrides
|
||||
virtual void bind(const CNetworkAddress&) throw(XSocket);
|
||||
virtual void connect(const CNetworkAddress&) throw(XSocket);
|
||||
virtual void close() throw(XIO);
|
||||
virtual IInputStream* getInputStream() throw();
|
||||
virtual IOutputStream* getOutputStream() throw();
|
||||
virtual void bind(const CNetworkAddress&);
|
||||
virtual void connect(const CNetworkAddress&);
|
||||
virtual void close();
|
||||
virtual IInputStream* getInputStream();
|
||||
virtual IOutputStream* getOutputStream();
|
||||
|
||||
private:
|
||||
void init() throw(XIO);
|
||||
void service(void*) throw(XThread);
|
||||
void closeInput(void*) throw();
|
||||
void closeOutput(void*) throw();
|
||||
void init();
|
||||
void service(void*);
|
||||
void closeInput(void*);
|
||||
void closeOutput(void*);
|
||||
|
||||
private:
|
||||
enum { kClosed = 0, kRead = 1, kWrite = 2, kReadWrite = 3 };
|
||||
|
||||
@@ -13,13 +13,13 @@ class IListenSocket : public IInterface {
|
||||
// manipulators
|
||||
|
||||
// bind the socket to a particular address
|
||||
virtual void bind(const CNetworkAddress&) throw(XSocket) = 0;
|
||||
virtual void bind(const CNetworkAddress&) = 0;
|
||||
|
||||
// wait for a connection
|
||||
virtual ISocket* accept() throw(XSocket) = 0;
|
||||
virtual ISocket* accept() = 0;
|
||||
|
||||
// close the socket
|
||||
virtual void close() throw(XIO) = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
// accessors
|
||||
};
|
||||
|
||||
@@ -15,19 +15,19 @@ class ISocket : public IInterface {
|
||||
// manipulators
|
||||
|
||||
// bind the socket to a particular address
|
||||
virtual void bind(const CNetworkAddress&) throw(XSocket) = 0;
|
||||
virtual void bind(const CNetworkAddress&) = 0;
|
||||
|
||||
// connect the socket
|
||||
virtual void connect(const CNetworkAddress&) throw(XSocket) = 0;
|
||||
virtual void connect(const CNetworkAddress&) = 0;
|
||||
|
||||
// close the socket. this will flush the output stream if it
|
||||
// hasn't been closed yet.
|
||||
virtual void close() throw(XIO) = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
// get the input and output streams for the socket. closing
|
||||
// these streams closes the appropriate half of the socket.
|
||||
virtual IInputStream* getInputStream() throw() = 0;
|
||||
virtual IOutputStream* getOutputStream() throw() = 0;
|
||||
virtual IInputStream* getInputStream() = 0;
|
||||
virtual IOutputStream* getOutputStream() = 0;
|
||||
|
||||
// accessors
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user