summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-15 17:58:45 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-15 17:58:45 +0000
commitbcd55729dd9367b3083d1e23c4d3a8c88756fabf (patch)
tree38d4dd12bf40c637269ba5a64328772fb1033413
parente84a1f15234090f4438604922cf826d27e25fb4a (diff)
downloadATCD-bcd55729dd9367b3083d1e23c4d3a8c88756fabf.tar.gz
Fixed force_active logic.
-rw-r--r--ace/Task.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/ace/Task.cpp b/ace/Task.cpp
index ed3f1cf599d..1080eb451cc 100644
--- a/ace/Task.cpp
+++ b/ace/Task.cpp
@@ -21,7 +21,7 @@ ACE_Task_Base::ACE_Task_Base (ACE_Thread_Manager *thr_man)
: thr_count_ (0),
thr_mgr_ (thr_man),
flags_ (0),
- grp_id_ (0)
+ grp_id_ (-1)
{
}
@@ -87,7 +87,11 @@ ACE_Task_Base::activate (long flags,
if (this->thr_count_ > 0 && force_active == 0)
return 1; // Already active.
else
- this->thr_count_ += n_threads;
+ {
+ this->thr_count_ += n_threads;
+ if (grp_id != -1)
+ grp_id = this->grp_id_;
+ }
// Use the ACE_Thread_Manager singleton if we're running as an
// active object and the caller didn't supply us with a
@@ -95,9 +99,10 @@ ACE_Task_Base::activate (long flags,
if (this->thr_mgr_ == 0)
this->thr_mgr_ = ACE_Thread_Manager::instance ();
+ int grp_spawned = -1;
if (thread_names == 0)
// thread names were not specified
- this->grp_id_ =
+ grp_spawned =
this->thr_mgr_->spawn_n (n_threads,
ACE_THR_FUNC (&ACE_Task_Base::svc_run),
(void *) this,
@@ -110,7 +115,7 @@ ACE_Task_Base::activate (long flags,
stack_size);
else
// thread names were specified
- this->grp_id_ =
+ grp_spawned =
this->thr_mgr_->spawn_n (thread_names,
n_threads,
ACE_THR_FUNC (&ACE_Task_Base::svc_run),
@@ -121,16 +126,18 @@ ACE_Task_Base::activate (long flags,
stack,
stack_size,
thread_handles);
- if (this->grp_id_ == -1)
+ if (grp_spawned == -1)
{
- // @@ This isn't 100% correct since spawn_n() may have spawned
- // some threads before it failed. However, this is better than
- // nothing...
+ // If spawn_n fails, restore original thread count.
this->thr_count_ -= n_threads;
return -1;
}
else
- return 0;
+ {
+ if (this->grp_id_ == -1)
+ this->grp_id_ = grp_spawned;
+ return 0;
+ }
#else
{
// Keep the compiler from complaining.