mirror of
https://github.com/reactos/wine.git
synced 2025-01-26 05:54:34 +00:00
Convert the object wait queue to a standard list.
This commit is contained in:
parent
dc457f0f9b
commit
aa34768677
@ -1324,7 +1324,7 @@ int default_fd_add_queue( struct object *obj, struct wait_queue_entry *entry )
|
||||
struct fd *fd = get_obj_fd( obj );
|
||||
|
||||
if (!fd) return 0;
|
||||
if (!obj->head) /* first on the queue */
|
||||
if (list_empty( &obj->wait_queue )) /* first on the queue */
|
||||
set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) );
|
||||
add_queue( obj, entry );
|
||||
release_object( fd );
|
||||
@ -1338,7 +1338,7 @@ void default_fd_remove_queue( struct object *obj, struct wait_queue_entry *entry
|
||||
|
||||
grab_object( obj );
|
||||
remove_queue( obj, entry );
|
||||
if (!obj->head) /* last on the queue is gone */
|
||||
if (list_empty( &obj->wait_queue )) /* last on the queue is gone */
|
||||
set_fd_events( fd, 0 );
|
||||
release_object( obj );
|
||||
release_object( fd );
|
||||
@ -1357,7 +1357,7 @@ int default_fd_signaled( struct object *obj, struct thread *thread )
|
||||
|
||||
if (ret)
|
||||
set_fd_events( fd, 0 ); /* stop waiting on select() if we are signaled */
|
||||
else if (obj->head)
|
||||
else if (!list_empty( &obj->wait_queue ))
|
||||
set_fd_events( fd, events ); /* restart waiting on poll() if we are no longer signaled */
|
||||
|
||||
release_object( fd );
|
||||
|
@ -137,9 +137,8 @@ void *alloc_object( const struct object_ops *ops )
|
||||
{
|
||||
obj->refcount = 1;
|
||||
obj->ops = ops;
|
||||
obj->head = NULL;
|
||||
obj->tail = NULL;
|
||||
obj->name = NULL;
|
||||
list_init( &obj->wait_queue );
|
||||
#ifdef DEBUG_OBJECTS
|
||||
list_add_head( &object_list, &obj->obj_list );
|
||||
#endif
|
||||
@ -205,8 +204,7 @@ void release_object( void *ptr )
|
||||
if (!--obj->refcount)
|
||||
{
|
||||
/* if the refcount is 0, nobody can be in the wait queue */
|
||||
assert( !obj->head );
|
||||
assert( !obj->tail );
|
||||
assert( list_empty( &obj->wait_queue ));
|
||||
obj->ops->destroy( obj );
|
||||
if (obj->name) free_name( obj );
|
||||
#ifdef DEBUG_OBJECTS
|
||||
|
@ -69,8 +69,7 @@ struct object
|
||||
{
|
||||
unsigned int refcount; /* reference count */
|
||||
const struct object_ops *ops;
|
||||
struct wait_queue_entry *head;
|
||||
struct wait_queue_entry *tail;
|
||||
struct list wait_queue;
|
||||
struct object_name *name;
|
||||
#ifdef DEBUG_OBJECTS
|
||||
struct list obj_list;
|
||||
@ -79,10 +78,9 @@ struct object
|
||||
|
||||
struct wait_queue_entry
|
||||
{
|
||||
struct wait_queue_entry *next;
|
||||
struct wait_queue_entry *prev;
|
||||
struct object *obj;
|
||||
struct thread *thread;
|
||||
struct list entry;
|
||||
struct object *obj;
|
||||
struct thread *thread;
|
||||
};
|
||||
|
||||
extern void *mem_alloc( size_t size ); /* malloc wrapper */
|
||||
|
@ -663,7 +663,7 @@ static int is_queue_hung( struct msg_queue *queue )
|
||||
if (now.tv_sec - queue->last_get_msg.tv_sec <= 5)
|
||||
return 0; /* less than 5 seconds since last get message -> not hung */
|
||||
|
||||
for (entry = queue->obj.head; entry; entry = entry->next)
|
||||
LIST_FOR_EACH_ENTRY( entry, &queue->obj.wait_queue, struct wait_queue_entry, entry )
|
||||
{
|
||||
if (entry->thread->queue == queue)
|
||||
return 0; /* thread is waiting on queue -> not hung */
|
||||
|
@ -342,22 +342,15 @@ static int resume_thread( struct thread *thread )
|
||||
int add_queue( struct object *obj, struct wait_queue_entry *entry )
|
||||
{
|
||||
grab_object( obj );
|
||||
entry->obj = obj;
|
||||
entry->prev = obj->tail;
|
||||
entry->next = NULL;
|
||||
if (obj->tail) obj->tail->next = entry;
|
||||
else obj->head = entry;
|
||||
obj->tail = entry;
|
||||
entry->obj = obj;
|
||||
list_add_tail( &obj->wait_queue, &entry->entry );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* remove a thread from an object wait queue */
|
||||
void remove_queue( struct object *obj, struct wait_queue_entry *entry )
|
||||
{
|
||||
if (entry->next) entry->next->prev = entry->prev;
|
||||
else obj->tail = entry->prev;
|
||||
if (entry->prev) entry->prev->next = entry->next;
|
||||
else obj->head = entry->next;
|
||||
list_remove( &entry->entry );
|
||||
release_object( obj );
|
||||
}
|
||||
|
||||
@ -569,13 +562,12 @@ done:
|
||||
/* attempt to wake threads sleeping on the object wait queue */
|
||||
void wake_up( struct object *obj, int max )
|
||||
{
|
||||
struct wait_queue_entry *entry = obj->head;
|
||||
struct list *ptr, *next;
|
||||
|
||||
while (entry)
|
||||
LIST_FOR_EACH_SAFE( ptr, next, &obj->wait_queue )
|
||||
{
|
||||
struct thread *thread = entry->thread;
|
||||
entry = entry->next;
|
||||
if (wake_thread( thread ))
|
||||
struct wait_queue_entry *entry = LIST_ENTRY( ptr, struct wait_queue_entry, entry );
|
||||
if (wake_thread( entry->thread ))
|
||||
{
|
||||
if (max && !--max) break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user