*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)

*Fix a possible crash in Spell::DoAllEffectOnTarget

--HG--
branch : trunk
This commit is contained in:
maximius
2009-10-17 15:35:07 -07:00
parent f21f47005d
commit 26b5e033ff
2257 changed files with 750 additions and 103852 deletions
-85
View File
@@ -1,11 +1,8 @@
// $Id: Reactor.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/Reactor.h"
#if !defined (ACE_LACKS_ACE_SVCCONF)
# include "ace/Service_Config.h"
#endif /* !ACE_LACKS_ACE_SVCCONF */
/*
* Hook to specialize the includes directly with the concrete
* Reactor type, e.g., select, thread pool reactor
@@ -36,36 +33,28 @@
# include "ace/WFMO_Reactor.h"
# endif /* ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL */
#endif /* !defined (ACE_WIN32) || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) */
/*
* End comment hook.
*/
//@@ REACTOR_SPL_COMMENT_INCLUDE_END_HOOK
#include "ace/Static_Object_Lock.h"
#include "ace/Framework_Component.h"
#include "ace/Guard_T.h"
#include "ace/Recursive_Thread_Mutex.h"
#if !defined (__ACE_INLINE__)
#include "ace/Reactor.inl"
#endif /* __ACE_INLINE__ */
ACE_RCSID (ace,
Reactor,
"$Id: Reactor.cpp 80826 2008-03-04 14:51:23Z wotte $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_Reactor)
ACE_Reactor::ACE_Reactor (ACE_Reactor_Impl *impl,
bool delete_implementation)
: implementation_ (0),
delete_implementation_ (delete_implementation)
{
this->implementation (impl);
if (this->implementation () == 0)
{
/*
@@ -101,42 +90,34 @@ ACE_Reactor::ACE_Reactor (ACE_Reactor_Impl *impl,
ACE_WFMO_Reactor);
#endif /* ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL */
#endif /* !defined (ACE_WIN32) || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) */
/*
* End hook.
*/
//@@ REACTOR_SPL_CONSTRUCTOR_COMMENT_HOOK_END
this->implementation (impl);
this->delete_implementation_ = true;
}
}
ACE_Reactor::~ACE_Reactor (void)
{
this->implementation ()->close ();
if (this->delete_implementation_)
delete this->implementation ();
}
// Process-wide ACE_Reactor.
ACE_Reactor *ACE_Reactor::reactor_ = 0;
// Controls whether the Reactor is deleted when we shut down (we can
// only delete it safely if we created it!)
bool ACE_Reactor::delete_reactor_ = false;
ACE_Reactor *
ACE_Reactor::instance (void)
{
ACE_TRACE ("ACE_Reactor::instance");
if (ACE_Reactor::reactor_ == 0)
{
// Perform Double-Checked Locking Optimization.
ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
*ACE_Static_Object_Lock::instance (), 0));
if (ACE_Reactor::reactor_ == 0)
{
ACE_NEW_RETURN (ACE_Reactor::reactor_,
@@ -148,36 +129,28 @@ ACE_Reactor::instance (void)
}
return ACE_Reactor::reactor_;
}
ACE_Reactor *
ACE_Reactor::instance (ACE_Reactor *r, bool delete_reactor)
{
ACE_TRACE ("ACE_Reactor::instance");
ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
*ACE_Static_Object_Lock::instance (), 0));
ACE_Reactor *t = ACE_Reactor::reactor_;
ACE_Reactor::delete_reactor_ = delete_reactor;
ACE_Reactor::reactor_ = r;
// We can't register the Reactor singleton as a framework component twice.
// Therefore we test to see if we had an existing reactor instance, which
// if so means it must have already been registered.
if (t == 0)
ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Reactor, ACE_Reactor::reactor_);
return t;
}
void
ACE_Reactor::close_singleton (void)
{
ACE_TRACE ("ACE_Reactor::close_singleton");
ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
*ACE_Static_Object_Lock::instance ()));
if (ACE_Reactor::delete_reactor_)
{
delete ACE_Reactor::reactor_;
@@ -185,19 +158,16 @@ ACE_Reactor::close_singleton (void)
ACE_Reactor::delete_reactor_ = false;
}
}
const ACE_TCHAR *
ACE_Reactor::dll_name (void)
{
return ACE_TEXT ("ACE");
}
const ACE_TCHAR *
ACE_Reactor::name (void)
{
return ACE_TEXT ("ACE_Reactor");
}
int
ACE_Reactor::check_reconfiguration (ACE_Reactor *)
{
@@ -210,19 +180,15 @@ ACE_Reactor::check_reconfiguration (ACE_Reactor *)
#endif /* ! ACE_HAS_WINCE || ! ACE_LACKS_ACE_SVCCONF */
return 0;
}
int
ACE_Reactor::run_reactor_event_loop (REACTOR_EVENT_HOOK eh)
{
ACE_TRACE ("ACE_Reactor::run_reactor_event_loop");
if (this->reactor_event_loop_done ())
return 0;
while (1)
{
int const result = this->implementation_->handle_events ();
if (eh != 0 && (*eh)(this))
continue;
else if (result == -1 && this->implementation_->deactivated ())
@@ -230,22 +196,17 @@ ACE_Reactor::run_reactor_event_loop (REACTOR_EVENT_HOOK eh)
else if (result == -1)
return -1;
}
ACE_NOTREACHED (return 0;)
}
int
ACE_Reactor::run_alertable_reactor_event_loop (REACTOR_EVENT_HOOK eh)
{
ACE_TRACE ("ACE_Reactor::run_alertable_reactor_event_loop");
if (this->reactor_event_loop_done ())
return 0;
while (1)
{
int const result = this->implementation_->alertable_handle_events ();
if (eh != 0 && (*eh)(this))
continue;
else if (result == -1 && this->implementation_->deactivated ())
@@ -253,23 +214,18 @@ ACE_Reactor::run_alertable_reactor_event_loop (REACTOR_EVENT_HOOK eh)
else if (result == -1)
return -1;
}
ACE_NOTREACHED (return 0;)
}
int
ACE_Reactor::run_reactor_event_loop (ACE_Time_Value &tv,
REACTOR_EVENT_HOOK eh)
{
ACE_TRACE ("ACE_Reactor::run_reactor_event_loop");
if (this->reactor_event_loop_done ())
return 0;
while (1)
{
int result = this->implementation_->handle_events (tv);
if (eh != 0 && (*eh) (this))
continue;
else if (result == -1)
@@ -295,23 +251,18 @@ ACE_Reactor::run_reactor_event_loop (ACE_Time_Value &tv,
}
// Else there were some events dispatched; go around again
}
ACE_NOTREACHED (return 0;)
}
int
ACE_Reactor::run_alertable_reactor_event_loop (ACE_Time_Value &tv,
REACTOR_EVENT_HOOK eh)
{
ACE_TRACE ("ACE_Reactor::run_alertable_reactor_event_loop");
if (this->reactor_event_loop_done ())
return 0;
for (;;)
{
int result = this->implementation_->alertable_handle_events (tv);
if (eh != 0 && (*eh)(this))
continue;
else if (result == -1 && this->implementation_->deactivated ())
@@ -320,25 +271,20 @@ ACE_Reactor::run_alertable_reactor_event_loop (ACE_Time_Value &tv,
return result;
}
}
int
ACE_Reactor::register_handler (ACE_Event_Handler *event_handler,
ACE_Reactor_Mask mask)
{
// Remember the old reactor.
ACE_Reactor *old_reactor = event_handler->reactor ();
// Assign *this* <Reactor> to the <Event_Handler>.
event_handler->reactor (this);
int result = this->implementation ()->register_handler (event_handler, mask);
if (result == -1)
// Reset the old reactor in case of failures.
event_handler->reactor (old_reactor);
return result;
}
int
ACE_Reactor::register_handler (ACE_HANDLE io_handle,
ACE_Event_Handler *event_handler,
@@ -346,43 +292,33 @@ ACE_Reactor::register_handler (ACE_HANDLE io_handle,
{
// Remember the old reactor.
ACE_Reactor *old_reactor = event_handler->reactor ();
// Assign *this* <Reactor> to the <Event_Handler>.
event_handler->reactor (this);
int result = this->implementation ()->register_handler (io_handle,
event_handler,
mask);
if (result == -1)
// Reset the old reactor in case of failures.
event_handler->reactor (old_reactor);
return result;
}
#if defined (ACE_WIN32)
int
ACE_Reactor::register_handler (ACE_Event_Handler *event_handler,
ACE_HANDLE event_handle)
{
// Remember the old reactor.
ACE_Reactor *old_reactor = event_handler->reactor ();
// Assign *this* <Reactor> to the <Event_Handler>.
event_handler->reactor (this);
int result = this->implementation ()->register_handler (event_handler,
event_handle);
if (result == -1)
// Reset the old reactor in case of failures.
event_handler->reactor (old_reactor);
return result;
}
#endif /* ACE_WIN32 */
int
ACE_Reactor::register_handler (ACE_HANDLE event_handle,
ACE_HANDLE io_handle,
@@ -391,10 +327,8 @@ ACE_Reactor::register_handler (ACE_HANDLE event_handle,
{
// Remember the old reactor.
ACE_Reactor *old_reactor = event_handler->reactor ();
// Assign *this* <Reactor> to the <Event_Handler>.
event_handler->reactor (this);
int result = this->implementation ()->register_handler (event_handle,
io_handle,
event_handler,
@@ -402,10 +336,8 @@ ACE_Reactor::register_handler (ACE_HANDLE event_handle,
if (result == -1)
// Reset the old reactor in case of failures.
event_handler->reactor (old_reactor);
return result;
}
int
ACE_Reactor::register_handler (const ACE_Handle_Set &handles,
ACE_Event_Handler *event_handler,
@@ -413,20 +345,16 @@ ACE_Reactor::register_handler (const ACE_Handle_Set &handles,
{
// Remember the old reactor.
ACE_Reactor *old_reactor = event_handler->reactor ();
// Assign *this* <Reactor> to the <Event_Handler>.
event_handler->reactor (this);
int result = this->implementation ()->register_handler (handles,
event_handler,
mask);
if (result == -1)
// Reset the old reactor in case of failures.
event_handler->reactor (old_reactor);
return result;
}
long
ACE_Reactor::schedule_timer (ACE_Event_Handler *event_handler,
const void *arg,
@@ -435,10 +363,8 @@ ACE_Reactor::schedule_timer (ACE_Event_Handler *event_handler,
{
// Remember the old reactor.
ACE_Reactor *old_reactor = event_handler->reactor ();
// Assign *this* <Reactor> to the <Event_Handler>.
event_handler->reactor (this);
long result = this->implementation ()->schedule_timer (event_handler,
arg,
delta,
@@ -446,29 +372,23 @@ ACE_Reactor::schedule_timer (ACE_Event_Handler *event_handler,
if (result == -1)
// Reset the old reactor in case of failures.
event_handler->reactor (old_reactor);
return result;
}
int
ACE_Reactor::schedule_wakeup (ACE_Event_Handler *event_handler,
ACE_Reactor_Mask masks_to_be_added)
{
// Remember the old reactor.
ACE_Reactor *old_reactor = event_handler->reactor ();
// Assign *this* <Reactor> to the <Event_Handler>.
event_handler->reactor (this);
int result = this->implementation ()->schedule_wakeup (event_handler,
masks_to_be_added);
if (result == -1)
// Reset the old reactor in case of failures.
event_handler->reactor (old_reactor);
return result;
}
int
ACE_Reactor::notify (ACE_Event_Handler *event_handler,
ACE_Reactor_Mask mask,
@@ -480,17 +400,14 @@ ACE_Reactor::notify (ACE_Event_Handler *event_handler,
event_handler->reactor (this);
return this->implementation ()->notify (event_handler, mask, tv);
}
int
ACE_Reactor::reset_timer_interval
(long timer_id,
const ACE_Time_Value &interval)
{
ACE_TRACE ("ACE_Reactor::reset_timer_interval");
return this->implementation ()->reset_timer_interval (timer_id, interval);
}
int
ACE_Reactor::cancel_timer (ACE_Event_Handler *event_handler,
int dont_call_handle_close)
@@ -498,7 +415,6 @@ ACE_Reactor::cancel_timer (ACE_Event_Handler *event_handler,
return this->implementation ()->cancel_timer (event_handler,
dont_call_handle_close);
}
int
ACE_Reactor::cancel_timer (long timer_id,
const void **arg,
@@ -508,6 +424,5 @@ ACE_Reactor::cancel_timer (long timer_id,
arg,
dont_call_handle_close);
}
ACE_END_VERSIONED_NAMESPACE_DECL