[haiku-commits] r40171 - in haiku/branches/developer/bonefish/signals: headers/private/kernel src/system/kernel

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 9 Jan 2011 00:05:09 +0100 (CET)

Author: bonefish
Date: 2011-01-09 00:05:09 +0100 (Sun, 09 Jan 2011)
New Revision: 40171
Changeset: http://dev.haiku-os.org/changeset/40171

Modified:
   
haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h
   haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp
   haiku/branches/developer/bonefish/signals/src/system/kernel/thread.cpp
Log:
Removed the indirection for Team::{dead,stopped,continued}_children.


Modified: 
haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h
===================================================================
--- 
haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h 
    2011-01-08 22:23:21 UTC (rev 40170)
+++ 
haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h 
    2011-01-08 23:05:09 UTC (rev 40171)
@@ -237,11 +237,9 @@
        struct list             dead_threads;
        int                             dead_threads_count;
 
-       // TODO: Remove the no longer necessary level of indirection for the
-       // following members.
-       team_dead_children *dead_children;
-       team_job_control_children *stopped_children;
-       team_job_control_children *continued_children;
+       team_dead_children dead_children;
+       team_job_control_children stopped_children;
+       team_job_control_children continued_children;
        struct job_control_entry* job_control_entry;
 
        VMAddressSpace  *address_space;

Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp
===================================================================
--- haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp        
2011-01-08 22:23:21 UTC (rev 40170)
+++ haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp        
2011-01-08 23:05:09 UTC (rev 40171)
@@ -522,10 +522,10 @@
        }
 
        // move job control entries too
-       sKernelTeam->stopped_children->entries.MoveFrom(
-               &team->stopped_children->entries);
-       sKernelTeam->continued_children->entries.MoveFrom(
-               &team->continued_children->entries);
+       sKernelTeam->stopped_children.entries.MoveFrom(
+               &team->stopped_children.entries);
+       sKernelTeam->continued_children.entries.MoveFrom(
+               &team->continued_children.entries);
 
        // Note, we don't move the dead children entries. Those will be deleted
        // when the team structure is deleted.
@@ -775,29 +775,10 @@
        team->dead_threads_count = 0;
 
        // dead children
-       team->dead_children = new(nothrow) team_dead_children;
-       if (team->dead_children == NULL)
-               return NULL;
-       ObjectDeleter<team_dead_children> 
deadChildrenDeleter(team->dead_children);
+       team->dead_children.count = 0;
+       team->dead_children.kernel_time = 0;
+       team->dead_children.user_time = 0;
 
-       team->dead_children->count = 0;
-       team->dead_children->kernel_time = 0;
-       team->dead_children->user_time = 0;
-
-       // stopped children
-       team->stopped_children = new(nothrow) team_job_control_children;
-       if (team->stopped_children == NULL)
-               return NULL;
-       ObjectDeleter<team_job_control_children> stoppedChildrenDeleter(
-               team->stopped_children);
-
-       // continued children
-       team->continued_children = new(nothrow) team_job_control_children;
-       if (team->continued_children == NULL)
-               return NULL;
-       ObjectDeleter<team_job_control_children> continuedChildrenDeleter(
-               team->continued_children);
-
        // job control entry
        team->job_control_entry = new(nothrow) job_control_entry;
        if (team->job_control_entry == NULL)
@@ -819,14 +800,11 @@
                return NULL;
 
        // publish dead/stopped/continued children condition vars
-       team->dead_children->condition_variable.Init(team->dead_children,
+       team->dead_children.condition_variable.Init(&team->dead_children,
                "team children");
 
        // keep all allocated structures
        jobControlEntryDeleter.Detach();
-       continuedChildrenDeleter.Detach();
-       stoppedChildrenDeleter.Detach();
-       deadChildrenDeleter.Detach();
        teamDeleter.Detach();
 
        return team;
@@ -844,7 +822,7 @@
                free(threadDeathEntry);
        }
 
-       while (job_control_entry* entry = 
team->dead_children->entries.RemoveHead())
+       while (job_control_entry* entry = 
team->dead_children.entries.RemoveHead())
                delete entry;
 
        while (free_user_thread* entry = team->free_user_threads) {
@@ -856,9 +834,6 @@
 
        delete team->job_control_entry;
                // usually already NULL and transferred to the parent
-       delete team->continued_children;
-       delete team->stopped_children;
-       delete team->dead_children;
        delete team;
 }
 
@@ -1722,9 +1697,9 @@
 
 
 static job_control_entry*
-get_job_control_entry(team_job_control_children* children, pid_t id)
+get_job_control_entry(team_job_control_children& children, pid_t id)
 {
-       for (JobControlEntryList::Iterator it = children->entries.GetIterator();
+       for (JobControlEntryList::Iterator it = children.entries.GetIterator();
                 job_control_entry* entry = it.Next();) {
 
                if (id > 0) {
@@ -1869,8 +1844,8 @@
                        if (entry->state == JOB_CONTROL_STATE_DEAD) {
                                // The child is dead. Reap its death entry.
                                freeDeathEntry = entry;
-                               team->dead_children->entries.Remove(entry);
-                               team->dead_children->count--;
+                               team->dead_children.entries.Remove(entry);
+                               team->dead_children.count--;
                        } else {
                                // The child is well. Reset its job control 
state.
                                team_set_job_control_state(entry->team,
@@ -1883,7 +1858,7 @@
                ConditionVariableEntry deadWaitEntry;
 
                if (status == B_WOULD_BLOCK && (flags & WNOHANG) == 0)
-                       
team->dead_children->condition_variable.Add(&deadWaitEntry);
+                       
team->dead_children.condition_variable.Add(&deadWaitEntry);
 
                locker.Unlock();
 
@@ -2164,8 +2139,8 @@
        if (entry) {
                // remove the entry only, if the caller is the parent of the 
found team
                if (team_get_current_team_id() == entry->thread) {
-                       team->dead_children->entries.Remove(entry);
-                       team->dead_children->count--;
+                       team->dead_children.entries.Remove(entry);
+                       team->dead_children.count--;
                        *_deleteEntry = true;
                } else {
                        *_deleteEntry = false;
@@ -2314,10 +2289,10 @@
        Team* parent = team->parent;
 
        // remember how long this team lasted
-       parent->dead_children->kernel_time += team->dead_threads_kernel_time
-               + team->dead_children->kernel_time;
-       parent->dead_children->user_time += team->dead_threads_user_time
-               + team->dead_children->user_time;
+       parent->dead_children.kernel_time += team->dead_threads_kernel_time
+               + team->dead_children.kernel_time;
+       parent->dead_children.user_time += team->dead_threads_user_time
+               + team->dead_children.user_time;
 
        // Also grab the thread spinlock while removing the team from the hash.
        // This makes the following sequence safe: grab teams lock, lookup team,
@@ -2635,10 +2610,10 @@
                        // can't get here
                        break;
                case JOB_CONTROL_STATE_STOPPED:
-                       team->parent->stopped_children->entries.Remove(entry);
+                       team->parent->stopped_children.entries.Remove(entry);
                        break;
                case JOB_CONTROL_STATE_CONTINUED:
-                       team->parent->continued_children->entries.Remove(entry);
+                       team->parent->continued_children.entries.Remove(entry);
                        break;
        }
 
@@ -2652,20 +2627,20 @@
                        // entry doesn't get into any list
                        break;
                case JOB_CONTROL_STATE_DEAD:
-                       childList = team->parent->dead_children;
-                       team->parent->dead_children->count++;
+                       childList = &team->parent->dead_children;
+                       team->parent->dead_children.count++;
                        break;
                case JOB_CONTROL_STATE_STOPPED:
-                       childList = team->parent->stopped_children;
+                       childList = &team->parent->stopped_children;
                        break;
                case JOB_CONTROL_STATE_CONTINUED:
-                       childList = team->parent->continued_children;
+                       childList = &team->parent->continued_children;
                        break;
        }
 
        if (childList != NULL) {
                childList->entries.Add(entry);
-               team->parent->dead_children->condition_variable.NotifyAll(
+               team->parent->dead_children.condition_variable.NotifyAll(
                        threadsLocked);
        }
 }
@@ -3193,8 +3168,8 @@
                                userTime += child->dead_threads_user_time;
                        }
 
-                       kernelTime += team->dead_children->kernel_time;
-                       userTime += team->dead_children->user_time;
+                       kernelTime += team->dead_children.kernel_time;
+                       userTime += team->dead_children.user_time;
                        break;
                }
        }
@@ -3506,7 +3481,7 @@
        // Changing the process group might have changed the situation for a 
parent
        // waiting in wait_for_child(). Hence we notify it.
        if (status == B_OK)
-               
team->parent->dead_children->condition_variable.NotifyAll(false);
+               team->parent->dead_children.condition_variable.NotifyAll(false);
 
        locker.Unlock();
 

Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/thread.cpp
===================================================================
--- haiku/branches/developer/bonefish/signals/src/system/kernel/thread.cpp      
2011-01-08 22:23:21 UTC (rev 40170)
+++ haiku/branches/developer/bonefish/signals/src/system/kernel/thread.cpp      
2011-01-08 23:05:09 UTC (rev 40171)
@@ -1442,9 +1442,9 @@
                                // team_set_job_control_state() already moved 
our entry
                                // into the parent's list. We just check the 
soft limit of
                                // death entries.
-                               if (parent->dead_children->count > 
MAX_DEAD_CHILDREN) {
-                                       death = 
parent->dead_children->entries.RemoveHead();
-                                       parent->dead_children->count--;
+                               if (parent->dead_children.count > 
MAX_DEAD_CHILDREN) {
+                                       death = 
parent->dead_children.entries.RemoveHead();
+                                       parent->dead_children.count--;
                                } else
                                        death = NULL;
 


Other related posts:

  • » [haiku-commits] r40171 - in haiku/branches/developer/bonefish/signals: headers/private/kernel src/system/kernel - ingo_weinhold