Fix to compile with g++ 2.95.4.

This commit is contained in:
chris_kohlhoff 2005-09-01 14:25:39 +00:00
parent 5c7d97837a
commit d84fd9edb9
3 changed files with 72 additions and 40 deletions

View File

@ -23,6 +23,7 @@ nobase_include_HEADERS = \
asio/detail/buffer_resize_guard.hpp \
asio/detail/epoll_reactor.hpp \
asio/detail/event.hpp \
asio/detail/fd_set_adapter.hpp \
asio/detail/hash_map.hpp \
asio/detail/locking_dispatcher_impl.hpp \
asio/detail/locking_dispatcher_service.hpp \

View File

@ -0,0 +1,67 @@
//
// fd_set_adapter.hpp
// ~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_DETAIL_FD_SET_ADAPTER_HPP
#define ASIO_DETAIL_FD_SET_ADAPTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/push_options.hpp"
#include "asio/detail/socket_types.hpp"
namespace asio {
namespace detail {
// Adapts the FD_SET type to meet the Descriptor_Set concept's requirements.
class fd_set_adapter
{
public:
fd_set_adapter()
: max_descriptor_(invalid_socket)
{
FD_ZERO(&fd_set_);
}
void set(socket_type descriptor)
{
if (max_descriptor_ == invalid_socket || descriptor > max_descriptor_)
max_descriptor_ = descriptor;
FD_SET(descriptor, &fd_set_);
}
bool is_set(socket_type descriptor) const
{
return FD_ISSET(descriptor, &fd_set_) != 0;
}
operator fd_set*()
{
return &fd_set_;
}
socket_type max_descriptor() const
{
return max_descriptor_;
}
private:
fd_set fd_set_;
socket_type max_descriptor_;
};
} // namespace detail
} // namespace asio
#include "asio/detail/pop_options.hpp"
#endif // ASIO_DETAIL_FD_SET_ADAPTER_HPP

View File

@ -22,6 +22,7 @@
#include "asio/detail/pop_options.hpp"
#include "asio/detail/bind_handler.hpp"
#include "asio/detail/fd_set_adapter.hpp"
#include "asio/detail/hash_map.hpp"
#include "asio/detail/mutex.hpp"
#include "asio/detail/task_demuxer_service.hpp"
@ -193,12 +194,12 @@ private:
while (!stop)
{
// Set up the descriptor sets.
fd_set_adaptor read_fds;
fd_set_adapter read_fds;
read_fds.set(interrupter_.read_descriptor());
read_op_queue_.get_descriptors(read_fds);
fd_set_adaptor write_fds;
fd_set_adapter write_fds;
write_op_queue_.get_descriptors(write_fds);
fd_set_adaptor except_fds;
fd_set_adapter except_fds;
except_op_queue_.get_descriptors(except_fds);
socket_type max_fd = read_fds.max_descriptor();
if (write_fds.max_descriptor() > max_fd)
@ -308,43 +309,6 @@ private:
interrupter_.interrupt();
}
// Adapts the FD_SET type to meet the Descriptor_Set concept's requirements.
class fd_set_adaptor
{
public:
fd_set_adaptor()
: max_descriptor_(invalid_socket)
{
FD_ZERO(&fd_set_);
}
void set(socket_type descriptor)
{
if (max_descriptor_ == invalid_socket || descriptor > max_descriptor_)
max_descriptor_ = descriptor;
FD_SET(descriptor, &fd_set_);
}
bool is_set(socket_type descriptor) const
{
return FD_ISSET(descriptor, &fd_set_) != 0;
}
operator fd_set*()
{
return &fd_set_;
}
socket_type max_descriptor() const
{
return max_descriptor_;
}
private:
fd_set fd_set_;
socket_type max_descriptor_;
};
// Mutex to protect access to internal data.
asio::detail::mutex mutex_;