Update of /cvsroot/boost/boost/boost/asio/impl
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6071/boost/asio/impl
Modified Files:
read.ipp read_until.ipp write.ipp
Log Message:
Change strand implementation so that dispatch will execute a handler
immediately if called from within the strand.
Add hook function for customising handler dispatch.
Need to use reinterpret_cast when testing for enable_connection_aborted
socket option, to allow non-int socket options to compile correctly.
Index: read.ipp
===================================================================
RCS file: /cvsroot/boost/boost/boost/asio/impl/read.ipp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- read.ipp 18 Jun 2006 08:01:10 -0000 1.2
+++ read.ipp 5 Jul 2006 05:48:10 -0000 1.3
@@ -23,6 +23,7 @@
#include <boost/asio/detail/bind_handler.hpp>
#include <boost/asio/detail/consuming_buffers.hpp>
#include <boost/asio/detail/handler_alloc_helpers.hpp>
+#include <boost/asio/detail/handler_dispatch_helpers.hpp>
namespace boost {
namespace asio {
@@ -132,8 +133,7 @@
if (completion_condition_(e, total_transferred_)
|| buffers_.begin() == buffers_.end())
{
- stream_.io_service().dispatch(
- detail::bind_handler(handler_, e, total_transferred_));
+ handler_(e, total_transferred_);
}
else
{
@@ -141,23 +141,7 @@
}
}
- friend void* asio_handler_allocate(std::size_t size,
- read_handler<Async_Read_Stream, Mutable_Buffers,
- Completion_Condition, Handler>* this_handler)
- {
- return boost_asio_handler_alloc_helpers::allocate(
- size, &this_handler->handler_);
- }
-
- friend void asio_handler_deallocate(void* pointer, std::size_t size,
- read_handler<Async_Read_Stream, Mutable_Buffers,
- Completion_Condition, Handler>* this_handler)
- {
- boost_asio_handler_alloc_helpers::deallocate(
- pointer, size, &this_handler->handler_);
- }
-
- private:
+ //private:
Async_Read_Stream& stream_;
boost::asio::detail::consuming_buffers<
mutable_buffer, Mutable_Buffers> buffers_;
@@ -165,6 +149,36 @@
Completion_Condition completion_condition_;
Handler handler_;
};
+
+ template <typename Async_Read_Stream, typename Mutable_Buffers,
+ typename Completion_Condition, typename Handler>
+ inline void* asio_handler_allocate(std::size_t size,
+ read_handler<Async_Read_Stream, Mutable_Buffers,
+ Completion_Condition, Handler>* this_handler)
+ {
+ return boost_asio_handler_alloc_helpers::allocate(
+ size, &this_handler->handler_);
+ }
+
+ template <typename Async_Read_Stream, typename Mutable_Buffers,
+ typename Completion_Condition, typename Handler>
+ inline void asio_handler_deallocate(void* pointer, std::size_t size,
+ read_handler<Async_Read_Stream, Mutable_Buffers,
+ Completion_Condition, Handler>* this_handler)
+ {
+ boost_asio_handler_alloc_helpers::deallocate(
+ pointer, size, &this_handler->handler_);
+ }
+
+ template <typename Handler_To_Dispatch, typename Async_Read_Stream,
+ typename Mutable_Buffers, typename Completion_Condition, typename
Handler>
+ inline void asio_handler_dispatch(const Handler_To_Dispatch& handler,
+ read_handler<Async_Read_Stream, Mutable_Buffers,
+ Completion_Condition, Handler>* this_handler)
+ {
+ boost_asio_handler_dispatch_helpers::dispatch_handler(
+ handler, &this_handler->handler_);
+ }
} // namespace detail
template <typename Async_Read_Stream, typename Mutable_Buffers,
@@ -211,8 +225,7 @@
streambuf_.commit(bytes_transferred);
if (completion_condition_(e, total_transferred_))
{
- stream_.io_service().dispatch(
- detail::bind_handler(handler_, e, total_transferred_));
+ handler_(e, total_transferred_);
}
else
{
@@ -220,29 +233,43 @@
}
}
- friend void* asio_handler_allocate(std::size_t size,
- read_streambuf_handler<Async_Read_Stream, Allocator,
- Completion_Condition, Handler>* this_handler)
- {
- return boost_asio_handler_alloc_helpers::allocate(
- size, &this_handler->handler_);
- }
-
- friend void asio_handler_deallocate(void* pointer, std::size_t size,
- read_streambuf_handler<Async_Read_Stream, Allocator,
- Completion_Condition, Handler>* this_handler)
- {
- boost_asio_handler_alloc_helpers::deallocate(
- pointer, size, &this_handler->handler_);
- }
-
- private:
+ //private:
Async_Read_Stream& stream_;
boost::asio::basic_streambuf<Allocator>& streambuf_;
std::size_t total_transferred_;
Completion_Condition completion_condition_;
Handler handler_;
};
+
+ template <typename Async_Read_Stream, typename Allocator,
+ typename Completion_Condition, typename Handler>
+ inline void* asio_handler_allocate(std::size_t size,
+ read_streambuf_handler<Async_Read_Stream, Allocator,
+ Completion_Condition, Handler>* this_handler)
+ {
+ return boost_asio_handler_alloc_helpers::allocate(
+ size, &this_handler->handler_);
+ }
+
+ template <typename Async_Read_Stream, typename Allocator,
+ typename Completion_Condition, typename Handler>
+ inline void asio_handler_deallocate(void* pointer, std::size_t size,
+ read_streambuf_handler<Async_Read_Stream, Allocator,
+ Completion_Condition, Handler>* this_handler)
+ {
+ boost_asio_handler_alloc_helpers::deallocate(
+ pointer, size, &this_handler->handler_);
+ }
+
+ template <typename Handler_To_Dispatch, typename Async_Read_Stream,
+ typename Allocator, typename Completion_Condition, typename Handler>
+ inline void asio_handler_dispatch(const Handler_To_Dispatch& handler,
+ read_streambuf_handler<Async_Read_Stream, Allocator,
+ Completion_Condition, Handler>* this_handler)
+ {
+ boost_asio_handler_dispatch_helpers::dispatch_handler(
+ handler, &this_handler->handler_);
+ }
} // namespace detail
template <typename Async_Read_Stream, typename Allocator,
Index: read_until.ipp
===================================================================
RCS file: /cvsroot/boost/boost/boost/asio/impl/read_until.ipp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- read_until.ipp 18 Jun 2006 08:01:10 -0000 1.2
+++ read_until.ipp 5 Jul 2006 05:48:10 -0000 1.3
@@ -27,6 +27,7 @@
#include <boost/asio/detail/bind_handler.hpp>
#include <boost/asio/detail/const_buffers_iterator.hpp>
#include <boost/asio/detail/handler_alloc_helpers.hpp>
+#include <boost/asio/detail/handler_dispatch_helpers.hpp>
namespace boost {
namespace asio {
@@ -191,29 +192,41 @@
stream_.async_read_some(streambuf_.prepare(512), *this);
}
- friend void* asio_handler_allocate(std::size_t size,
- read_until_delim_handler<Async_Read_Stream,
- Allocator, Handler>* this_handler)
- {
- return boost_asio_handler_alloc_helpers::allocate(
- size, &this_handler->handler_);
- }
-
- friend void asio_handler_deallocate(void* pointer, std::size_t size,
- read_until_delim_handler<Async_Read_Stream,
- Allocator, Handler>* this_handler)
- {
- boost_asio_handler_alloc_helpers::deallocate(
- pointer, size, &this_handler->handler_);
- }
-
- private:
+ //private:
Async_Read_Stream& stream_;
boost::asio::basic_streambuf<Allocator>& streambuf_;
char delim_;
std::size_t next_search_start_;
Handler handler_;
};
+
+ template <typename Async_Read_Stream, typename Allocator, typename Handler>
+ inline void* asio_handler_allocate(std::size_t size,
+ read_until_delim_handler<Async_Read_Stream,
+ Allocator, Handler>* this_handler)
+ {
+ return boost_asio_handler_alloc_helpers::allocate(
+ size, &this_handler->handler_);
+ }
+
+ template <typename Async_Read_Stream, typename Allocator, typename Handler>
+ inline void asio_handler_deallocate(void* pointer, std::size_t size,
+ read_until_delim_handler<Async_Read_Stream,
+ Allocator, Handler>* this_handler)
+ {
+ boost_asio_handler_alloc_helpers::deallocate(
+ pointer, size, &this_handler->handler_);
+ }
+
+ template <typename Handler_To_Dispatch, typename Async_Read_Stream,
+ typename Allocator, typename Handler>
+ inline void asio_handler_dispatch(const Handler_To_Dispatch& handler,
+ read_until_delim_handler<Async_Read_Stream,
+ Allocator, Handler>* this_handler)
+ {
+ boost_asio_handler_dispatch_helpers::dispatch_handler(
+ handler, &this_handler->handler_);
+ }
} // namespace detail
template <typename Async_Read_Stream, typename Allocator, typename Handler>
@@ -316,29 +329,41 @@
stream_.async_read_some(streambuf_.prepare(512), *this);
}
- friend void* asio_handler_allocate(std::size_t size,
- read_until_expr_handler<Async_Read_Stream,
- Allocator, Handler>* this_handler)
- {
- return boost_asio_handler_alloc_helpers::allocate(
- size, &this_handler->handler_);
- }
-
- friend void asio_handler_deallocate(void* pointer, std::size_t size,
- read_until_expr_handler<Async_Read_Stream,
- Allocator, Handler>* this_handler)
- {
- boost_asio_handler_alloc_helpers::deallocate(
- pointer, size, &this_handler->handler_);
- }
-
- private:
+ //private:
Async_Read_Stream& stream_;
boost::asio::basic_streambuf<Allocator>& streambuf_;
boost::regex expr_;
std::size_t next_search_start_;
Handler handler_;
};
+
+ template <typename Async_Read_Stream, typename Allocator, typename Handler>
+ inline void* asio_handler_allocate(std::size_t size,
+ read_until_expr_handler<Async_Read_Stream,
+ Allocator, Handler>* this_handler)
+ {
+ return boost_asio_handler_alloc_helpers::allocate(
+ size, &this_handler->handler_);
+ }
+
+ template <typename Async_Read_Stream, typename Allocator, typename Handler>
+ inline void asio_handler_deallocate(void* pointer, std::size_t size,
+ read_until_expr_handler<Async_Read_Stream,
+ Allocator, Handler>* this_handler)
+ {
+ boost_asio_handler_alloc_helpers::deallocate(
+ pointer, size, &this_handler->handler_);
+ }
+
+ template <typename Handler_To_Dispatch, typename Async_Read_Stream,
+ typename Allocator, typename Handler>
+ inline void asio_handler_dispatch(const Handler_To_Dispatch& handler,
+ read_until_expr_handler<Async_Read_Stream,
+ Allocator, Handler>* this_handler)
+ {
+ boost_asio_handler_dispatch_helpers::dispatch_handler(
+ handler, &this_handler->handler_);
+ }
} // namespace detail
template <typename Async_Read_Stream, typename Allocator, typename Handler>
Index: write.ipp
===================================================================
RCS file: /cvsroot/boost/boost/boost/asio/impl/write.ipp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- write.ipp 18 Jun 2006 08:01:10 -0000 1.2
+++ write.ipp 5 Jul 2006 05:48:10 -0000 1.3
@@ -23,6 +23,7 @@
#include <boost/asio/detail/bind_handler.hpp>
#include <boost/asio/detail/consuming_buffers.hpp>
#include <boost/asio/detail/handler_alloc_helpers.hpp>
+#include <boost/asio/detail/handler_dispatch_helpers.hpp>
namespace boost {
namespace asio {
@@ -121,8 +122,7 @@
if (completion_condition_(e, total_transferred_)
|| buffers_.begin() == buffers_.end())
{
- stream_.io_service().dispatch(
- detail::bind_handler(handler_, e, total_transferred_));
+ handler_(e, total_transferred_);
}
else
{
@@ -130,23 +130,7 @@
}
}
- friend void* asio_handler_allocate(std::size_t size,
- write_handler<Async_Write_Stream, Const_Buffers,
- Completion_Condition, Handler>* this_handler)
- {
- return boost_asio_handler_alloc_helpers::allocate(
- size, &this_handler->handler_);
- }
-
- friend void asio_handler_deallocate(void* pointer, std::size_t size,
- write_handler<Async_Write_Stream, Const_Buffers,
- Completion_Condition, Handler>* this_handler)
- {
- boost_asio_handler_alloc_helpers::deallocate(
- pointer, size, &this_handler->handler_);
- }
-
- private:
+ //private:
Async_Write_Stream& stream_;
boost::asio::detail::consuming_buffers<
const_buffer, Const_Buffers> buffers_;
@@ -154,6 +138,36 @@
Completion_Condition completion_condition_;
Handler handler_;
};
+
+ template <typename Async_Write_Stream, typename Const_Buffers,
+ typename Completion_Condition, typename Handler>
+ inline void* asio_handler_allocate(std::size_t size,
+ write_handler<Async_Write_Stream, Const_Buffers,
+ Completion_Condition, Handler>* this_handler)
+ {
+ return boost_asio_handler_alloc_helpers::allocate(
+ size, &this_handler->handler_);
+ }
+
+ template <typename Async_Write_Stream, typename Const_Buffers,
+ typename Completion_Condition, typename Handler>
+ inline void asio_handler_deallocate(void* pointer, std::size_t size,
+ write_handler<Async_Write_Stream, Const_Buffers,
+ Completion_Condition, Handler>* this_handler)
+ {
+ boost_asio_handler_alloc_helpers::deallocate(
+ pointer, size, &this_handler->handler_);
+ }
+
+ template <typename Handler_To_Dispatch, typename Async_Write_Stream,
+ typename Const_Buffers, typename Completion_Condition, typename Handler>
+ inline void asio_handler_dispatch(const Handler_To_Dispatch& handler,
+ write_handler<Async_Write_Stream, Const_Buffers,
+ Completion_Condition, Handler>* this_handler)
+ {
+ boost_asio_handler_dispatch_helpers::dispatch_handler(
+ handler, &this_handler->handler_);
+ }
} // namespace detail
template <typename Async_Write_Stream, typename Const_Buffers,
@@ -194,26 +208,38 @@
handler_(e, bytes_transferred);
}
- friend void* asio_handler_allocate(std::size_t size,
- write_streambuf_handler<Async_Write_Stream,
- Allocator, Handler>* this_handler)
- {
- return boost_asio_handler_alloc_helpers::allocate(
- size, &this_handler->handler_);
- }
-
- friend void asio_handler_deallocate(void* pointer, std::size_t size,
- write_streambuf_handler<Async_Write_Stream,
- Allocator, Handler>* this_handler)
- {
- boost_asio_handler_alloc_helpers::deallocate(
- pointer, size, &this_handler->handler_);
- }
-
- private:
+ //private:
boost::asio::basic_streambuf<Allocator>& streambuf_;
Handler handler_;
};
+
+ template <typename Async_Write_Stream, typename Allocator, typename Handler>
+ inline void* asio_handler_allocate(std::size_t size,
+ write_streambuf_handler<Async_Write_Stream,
+ Allocator, Handler>* this_handler)
+ {
+ return boost_asio_handler_alloc_helpers::allocate(
+ size, &this_handler->handler_);
+ }
+
+ template <typename Async_Write_Stream, typename Allocator, typename Handler>
+ inline void asio_handler_deallocate(void* pointer, std::size_t size,
+ write_streambuf_handler<Async_Write_Stream,
+ Allocator, Handler>* this_handler)
+ {
+ boost_asio_handler_alloc_helpers::deallocate(
+ pointer, size, &this_handler->handler_);
+ }
+
+ template <typename Handler_To_Dispatch, typename Async_Write_Stream,
+ typename Allocator, typename Handler>
+ inline void asio_handler_dispatch(const Handler_To_Dispatch& handler,
+ write_streambuf_handler<Async_Write_Stream,
+ Allocator, Handler>* this_handler)
+ {
+ boost_asio_handler_dispatch_helpers::dispatch_handler(
+ handler, &this_handler->handler_);
+ }
} // namespace detail
template <typename Async_Write_Stream, typename Allocator,
@@ -222,7 +248,7 @@
boost::asio::basic_streambuf<Allocator>& b,
Completion_Condition completion_condition, Handler handler)
{
- async_write(s, b.data(),
+ async_write(s, b.data(), completion_condition,
detail::write_streambuf_handler<Async_Write_Stream, Allocator, Handler>(
b, handler));
}
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs