4 * Copyright (C) 1998 Alexandre Julliard
7 #ifndef __WINE_SERVER_THREAD_H
8 #define __WINE_SERVER_THREAD_H
10 #ifndef __WINE_SERVER__
11 #error This file can only be used in the Wine server
14 #include "server/object.h"
16 /* thread structure */
22 enum run_state { STARTING, RUNNING, TERMINATED };
26 struct object obj; /* object header */
27 struct thread *next; /* system-wide thread list */
29 struct thread *proc_next; /* per-process thread list */
30 struct thread *proc_prev;
31 struct process *process;
32 struct mutex *mutex; /* list of currently owned mutexes */
33 struct thread_wait *wait; /* current wait condition if sleeping */
34 int error; /* current error code */
35 enum run_state state; /* running state */
36 int exit_code; /* thread exit code */
37 int client_fd; /* client fd for socket communications */
38 int unix_pid; /* Unix pid of client */
39 enum request last_req; /* last request received (for debugging) */
43 extern struct thread *current;
45 /* thread functions */
47 extern struct thread *create_thread( int fd, void *pid, int *thread_handle,
48 int *process_handle );
49 extern struct thread *get_thread_from_id( void *id );
50 extern struct thread *get_thread_from_handle( int handle, unsigned int access );
51 extern void get_thread_info( struct thread *thread,
52 struct get_thread_info_reply *reply );
53 extern int send_reply( struct thread *thread, int pass_fd,
54 int n, ... /* arg_1, len_1, ..., arg_n, len_n */ );
55 extern void kill_thread( struct thread *thread, int exit_code );
56 extern void thread_killed( struct thread *thread, int exit_code );
57 extern void thread_timeout(void);
58 extern void sleep_on( struct thread *thread, int count, int *handles,
59 int flags, int timeout );
60 extern void wake_up( struct object *obj, int max );
62 #define GET_ERROR() (current->error)
63 #define SET_ERROR(err) (current->error = (err))
64 #define CLEAR_ERROR() (current->error = 0)
66 #endif /* __WINE_SERVER_THREAD_H */