* Added a "name changed" notification to the thread notification service.
* Added a "team" field to the notification events. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39861 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -25,9 +25,10 @@ struct thread_creation_attributes;
|
|||||||
|
|
||||||
|
|
||||||
// thread notifications
|
// thread notifications
|
||||||
#define THREAD_MONITOR '_tm_'
|
#define THREAD_MONITOR '_tm_'
|
||||||
#define THREAD_ADDED 0x01
|
#define THREAD_ADDED 0x01
|
||||||
#define THREAD_REMOVED 0x02
|
#define THREAD_REMOVED 0x02
|
||||||
|
#define THREAD_NAME_CHANGED 0x04
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -97,17 +97,25 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notify(uint32 eventCode, struct thread* thread)
|
void Notify(uint32 eventCode, team_id teamID, thread_id threadID,
|
||||||
|
struct thread* thread = NULL)
|
||||||
{
|
{
|
||||||
char eventBuffer[128];
|
char eventBuffer[128];
|
||||||
KMessage event;
|
KMessage event;
|
||||||
event.SetTo(eventBuffer, sizeof(eventBuffer), THREAD_MONITOR);
|
event.SetTo(eventBuffer, sizeof(eventBuffer), THREAD_MONITOR);
|
||||||
event.AddInt32("event", eventCode);
|
event.AddInt32("event", eventCode);
|
||||||
event.AddInt32("thread", thread->id);
|
event.AddInt32("team", teamID);
|
||||||
event.AddPointer("threadStruct", thread);
|
event.AddInt32("thread", threadID);
|
||||||
|
if (thread != NULL)
|
||||||
|
event.AddPointer("threadStruct", thread);
|
||||||
|
|
||||||
DefaultNotificationService::Notify(event, eventCode);
|
DefaultNotificationService::Notify(event, eventCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Notify(uint32 eventCode, struct thread* thread)
|
||||||
|
{
|
||||||
|
return Notify(eventCode, thread->id, thread->team->id, thread);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -2533,33 +2541,34 @@ find_thread(const char *name)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
rename_thread(thread_id id, const char *name)
|
rename_thread(thread_id id, const char* name)
|
||||||
{
|
{
|
||||||
struct thread *thread = thread_get_current_thread();
|
struct thread* thread = thread_get_current_thread();
|
||||||
status_t status = B_BAD_THREAD_ID;
|
|
||||||
cpu_status state;
|
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
state = disable_interrupts();
|
InterruptsSpinLocker locker(gThreadSpinlock);
|
||||||
GRAB_THREAD_LOCK();
|
|
||||||
|
|
||||||
if (thread->id != id)
|
if (thread->id != id) {
|
||||||
thread = thread_get_thread_struct_locked(id);
|
thread = thread_get_thread_struct_locked(id);
|
||||||
|
if (thread == NULL)
|
||||||
if (thread != NULL) {
|
return B_BAD_THREAD_ID;
|
||||||
if (thread->team == thread_get_current_thread()->team) {
|
if (thread->team != thread_get_current_thread()->team)
|
||||||
strlcpy(thread->name, name, B_OS_NAME_LENGTH);
|
return B_NOT_ALLOWED;
|
||||||
status = B_OK;
|
|
||||||
} else
|
|
||||||
status = B_NOT_ALLOWED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RELEASE_THREAD_LOCK();
|
strlcpy(thread->name, name, B_OS_NAME_LENGTH);
|
||||||
restore_interrupts(state);
|
|
||||||
|
|
||||||
return status;
|
team_id teamID = thread->team->id;
|
||||||
|
|
||||||
|
locker.Unlock();
|
||||||
|
|
||||||
|
// notify listeners
|
||||||
|
sNotificationService.Notify(THREAD_NAME_CHANGED, teamID, id);
|
||||||
|
// don't pass the thread structure, as it's unsafe, if it isn't ours
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user