|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64036 - sandbox/SOC/2010/process/boost/process/detail
From: fotanus_at_[hidden]
Date: 2010-07-14 23:57:14
Author: fotanus
Date: 2010-07-14 23:57:12 EDT (Wed, 14 Jul 2010)
New Revision: 64036
URL: http://svn.boost.org/trac/boost/changeset/64036
Log:
POSIX update:
* Retested all features from matriz
* Modified status to make it compile; async wait should not be working.
Text files modified:
sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp | 31 ++++++++++++++++++++++++++++---
sandbox/SOC/2010/process/boost/process/detail/status_impl.hpp | 24 +++++++++++++++++++++---
2 files changed, 49 insertions(+), 6 deletions(-)
Modified: sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp 2010-07-14 23:57:12 EDT (Wed, 14 Jul 2010)
@@ -49,25 +49,35 @@
: public boost::asio::detail::service_base<StatusImplementation>
{
public:
+
+
+ typedef boost::shared_ptr<StatusImplementation> implementation_type;
+
explicit basic_status_service(boost::asio::io_service &io_service)
: boost::asio::detail::service_base<StatusImplementation>(io_service),
run_(true),
work_thread_(&basic_status_service<StatusImplementation>::work_thread, this)
{
+#if defined(BOOST_WINDOWS_API)
handles_.push_back(::CreateEvent(NULL, FALSE, FALSE, NULL));
if (handles_[0] == NULL)
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("CreateEvent() failed");
+#endif
}
~basic_status_service()
{
stop_work_thread();
work_thread_.join();
+#if defined(BOOST_WINDOWS_API)
if (!::CloseHandle(handles_[0]))
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("CloseHandle() failed");
+#elif defined(BOOST_POSIX_API)
+ if (::close(handles_[0]) == -1)
+ BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("close() failed");
+#endif
}
- typedef boost::shared_ptr<StatusImplementation> implementation_type;
void construct(implementation_type &impl)
{
@@ -97,10 +107,13 @@
template <typename Handler>
void async_wait(implementation_type &impl, pid_type pid, Handler handler)
{
+#if defined(BOOST_WINDOWS_API)
HANDLE handle = ::OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, FALSE, pid);
if (handle == NULL)
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("OpenProcess() failed");
-
+#elif defined(BOOST_POSIX_API)
+ behavior::stream::native_type handle = pid;
+#endif
boost::unique_lock<boost::mutex> lock(work_thread_mutex_);
interrupt_work_thread();
work_thread_cond_.wait(work_thread_mutex_);
@@ -111,6 +124,7 @@
work_thread_cond_.notify_all();
}
+
private:
void shutdown_service()
{
@@ -120,6 +134,7 @@
{
while (running())
{
+#if defined(BOOST_WINDOWS_API)
DWORD res = ::WaitForMultipleObjects(handles_.size(), &handles_[0], FALSE, INFINITE);
if (res == WAIT_FAILED)
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("WaitForMultipleObjects() failed");
@@ -146,6 +161,9 @@
if (handles_.size() == 1)
work_.reset();
}
+#elif defined(BOOST_POSIX_API)
+ //linux here
+#endif
}
}
@@ -160,8 +178,12 @@
{
// By signaling the event in the first slot WaitForMultipleObjects() will return.
// The work thread won't do anything except checking if it should continue to run.
+#if defined(BOOST_WINDOWS_API)
if (!::SetEvent(handles_[0]))
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("SetEvent() failed");
+#elif defined(BOOST_POSIX_API)
+ //linux here
+#endif
}
void stop_work_thread()
@@ -178,7 +200,10 @@
boost::condition_variable_any work_thread_cond_;
bool run_;
boost::thread work_thread_;
- std::vector<HANDLE> handles_;
+ std::vector<behavior::stream::native_type> handles_;
+
+
+
};
}
Modified: sandbox/SOC/2010/process/boost/process/detail/status_impl.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/status_impl.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/detail/status_impl.hpp 2010-07-14 23:57:12 EDT (Wed, 14 Jul 2010)
@@ -23,6 +23,7 @@
#include <boost/system/error_code.hpp>
#include <boost/ptr_container/ptr_unordered_map.hpp>
#include <boost/bind.hpp>
+#include <boost/process/stream_behavior.hpp>
#include <algorithm>
#if defined(BOOST_POSIX_API)
@@ -38,7 +39,11 @@
struct operation
{
+ #if defined(BOOST_WINDOWS_API)
virtual void operator()(DWORD exit_code)
+ #elif defined BOOST_POSIX_API
+ virtual void operator()(unsigned int exit_code)
+ #endif
{
}
};
@@ -52,7 +57,11 @@
{
}
+ #if defined(BOOST_WINDOWS_API)
void operator()(DWORD exit_code)
+ #elif defined BOOST_POSIX_API
+ void operator()(unsigned int exit_code)
+ #endif
{
handler_(boost::system::error_code(), exit_code);
}
@@ -65,23 +74,32 @@
{
public:
template <typename Handler>
- void async_wait(HANDLE handle, Handler handler)
+ void async_wait(behavior::stream::native_type handle, Handler handler)
{
ops_.insert(handle, new wrapped_handler<Handler>(handler));
}
- void complete(HANDLE handle, DWORD exit_code)
+ #if defined(BOOST_WINDOWS_API)
+ void complete(behavior::stream::native_type handle, DWORD exit_code)
+ #elif defined(BOOST_POSIX_API)
+ void complete(behavior::stream::native_type handle, unsigned int exit_code)
+ #endif
{
boost::iterator_range<operations_type::iterator> r = ops_.equal_range(handle);
for (operations_type::iterator it = r.begin(); it != r.end(); ++it)
(*it->second)(exit_code);
ops_.erase(r.begin(), r.end());
+ #if defined(BOOST_WINDOWS_API)
if (!::CloseHandle(handle))
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("CloseHandle() failed");
+ #elif defined(BOOST_POSIX_API)
+ if (::close(handle) == -1)
+ BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("close() failed");
+ #endif
}
private:
- typedef boost::ptr_unordered_multimap<HANDLE, operation> operations_type;
+ typedef boost::ptr_unordered_multimap<behavior::stream::native_type, operation> operations_type;
operations_type ops_;
};
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk