* Implemented a generic way to associate data with a team which is
automatically cleaned up when the team is deleted: Class AssociatedData is the base class for a data item, AssociatedDataOwner a container for them (struct team derives from it). Functions team_associate_data() and team_dissociate_data() add/remove data. * Turned sTeamHash into a BOpenHashTable (necessary since struct team is no longer a POD). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39860 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -63,6 +63,9 @@ status_t stop_watching_team(team_id team, void (*hook)(team_id, void *),
|
||||
struct user_thread* team_allocate_user_thread(struct team* team);
|
||||
void team_free_user_thread(struct thread* thread);
|
||||
|
||||
bool team_associate_data(AssociatedData* data);
|
||||
bool team_dissociate_data(AssociatedData* data);
|
||||
|
||||
// used in syscalls.c
|
||||
thread_id _user_load_image(const char* const* flatArgs, size_t flatArgsSize,
|
||||
int32 argCount, int32 envCount, int32 priority, uint32 flags,
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
|
||||
#ifndef _ASSEMBLER
|
||||
|
||||
#include <Referenceable.h>
|
||||
|
||||
#include <arch/thread_types.h>
|
||||
#include <condition_variable.h>
|
||||
#include <lock.h>
|
||||
#include <signal.h>
|
||||
#include <smp.h>
|
||||
#include <thread_defs.h>
|
||||
@@ -58,6 +61,7 @@ typedef enum job_control_state {
|
||||
struct image; // defined in image.c
|
||||
struct io_context;
|
||||
struct realtime_sem_context; // defined in realtime_sem.cpp
|
||||
struct scheduler_thread_data;
|
||||
struct select_info;
|
||||
struct user_thread; // defined in libroot/user_thread.h
|
||||
struct xsi_sem_context; // defined in xsi_semaphore.cpp
|
||||
@@ -154,9 +158,48 @@ struct free_user_thread {
|
||||
struct user_thread* thread;
|
||||
};
|
||||
|
||||
struct scheduler_thread_data;
|
||||
|
||||
struct team {
|
||||
class AssociatedDataOwner;
|
||||
|
||||
class AssociatedData : public Referenceable,
|
||||
public DoublyLinkedListLinkImpl<AssociatedData> {
|
||||
public:
|
||||
AssociatedData();
|
||||
virtual ~AssociatedData();
|
||||
|
||||
AssociatedDataOwner* Owner() const
|
||||
{ return fOwner; }
|
||||
void SetOwner(AssociatedDataOwner* owner)
|
||||
{ fOwner = owner; }
|
||||
|
||||
virtual void OwnerDeleted(AssociatedDataOwner* owner);
|
||||
|
||||
private:
|
||||
AssociatedDataOwner* fOwner;
|
||||
};
|
||||
|
||||
|
||||
class AssociatedDataOwner {
|
||||
public:
|
||||
AssociatedDataOwner();
|
||||
~AssociatedDataOwner();
|
||||
|
||||
bool AddData(AssociatedData* data);
|
||||
bool RemoveData(AssociatedData* data);
|
||||
|
||||
void PrepareForDeletion();
|
||||
|
||||
private:
|
||||
typedef DoublyLinkedList<AssociatedData> DataList;
|
||||
|
||||
private:
|
||||
|
||||
mutex fLock;
|
||||
DataList fList;
|
||||
};
|
||||
|
||||
|
||||
struct team : AssociatedDataOwner {
|
||||
struct team *next; // next in hash
|
||||
struct team *siblings_next;
|
||||
struct team *parent;
|
||||
|
||||
Reference in New Issue
Block a user