Rev 1923 | Rev 2071 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1923 | Rev 1971 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | 34 | ||
35 | /** |
35 | /** |
36 | * Asynchronous library |
36 | * Asynchronous library |
37 | * |
37 | * |
38 | * The aim of this library is facilitating writing programs utilizing |
38 | * The aim of this library is facilitating writing programs utilizing |
39 | * the asynchronous nature of Helenos IPC, yet using a normal way |
39 | * the asynchronous nature of HelenOS IPC, yet using a normal way |
40 | * of programming. |
40 | * of programming. |
41 | * |
41 | * |
42 | * You should be able to write very simple multithreaded programs, |
42 | * You should be able to write very simple multithreaded programs, |
43 | * the async framework will automatically take care of most synchronization |
43 | * the async framework will automatically take care of most synchronization |
44 | * problems. |
44 | * problems. |
Line 77... | Line 77... | ||
77 | * } |
77 | * } |
78 | * ipc_answer_fast(icallid, 0, 0, 0); |
78 | * ipc_answer_fast(icallid, 0, 0, 0); |
79 | * |
79 | * |
80 | * callid = async_get_call(&call); |
80 | * callid = async_get_call(&call); |
81 | * handle(callid, call); |
81 | * handle(callid, call); |
82 | * ipc_answer_fast(callid, 1,2,3); |
82 | * ipc_answer_fast(callid, 1, 2, 3); |
83 | * |
83 | * |
84 | * callid = async_get_call(&call); |
84 | * callid = async_get_call(&call); |
85 | * .... |
85 | * .... |
86 | * } |
86 | * } |
87 | * |
87 | * |
Line 102... | Line 102... | ||
102 | atomic_t async_futex = FUTEX_INITIALIZER; |
102 | atomic_t async_futex = FUTEX_INITIALIZER; |
103 | static hash_table_t conn_hash_table; |
103 | static hash_table_t conn_hash_table; |
104 | static LIST_INITIALIZE(timeout_list); |
104 | static LIST_INITIALIZE(timeout_list); |
105 | 105 | ||
106 | typedef struct { |
106 | typedef struct { |
107 | struct timeval expires; /**< Expiration time for waiting thread */ |
107 | struct timeval expires; /**< Expiration time for waiting thread */ |
108 | int inlist; /**< If true, this struct is in timeout list */ |
108 | int inlist; /**< If true, this struct is in timeout list */ |
109 | link_t link; |
109 | link_t link; |
110 | 110 | ||
111 | pstid_t ptid; /**< Thread waiting for this message */ |
111 | pstid_t ptid; /**< Thread waiting for this message */ |
112 | int active; /**< If this thread is currently active */ |
112 | int active; /**< If this thread is currently active */ |
113 | int timedout; /**< If true, we timed out */ |
113 | int timedout; /**< If true, we timed out */ |
114 | } awaiter_t; |
114 | } awaiter_t; |
115 | 115 | ||
116 | typedef struct { |
116 | typedef struct { |
117 | awaiter_t wdata; |
117 | awaiter_t wdata; |
118 | 118 | ||
119 | int done; /**< If reply was received */ |
119 | int done; /**< If reply was received */ |
120 | ipc_call_t *dataptr; /**< Pointer where the answer data |
120 | ipc_call_t *dataptr; /**< Pointer where the answer data |
121 | * is stored */ |
121 | * is stored */ |
122 | ipcarg_t retval; |
122 | ipcarg_t retval; |
123 | } amsg_t; |
123 | } amsg_t; |
124 | 124 | ||
125 | typedef struct { |
125 | typedef struct { |
126 | link_t link; |
126 | link_t link; |
Line 129... | Line 129... | ||
129 | } msg_t; |
129 | } msg_t; |
130 | 130 | ||
131 | typedef struct { |
131 | typedef struct { |
132 | awaiter_t wdata; |
132 | awaiter_t wdata; |
133 | 133 | ||
134 | link_t link; /**< Hash table link */ |
134 | link_t link; /**< Hash table link */ |
135 | ipcarg_t in_phone_hash; /**< Incoming phone hash. */ |
135 | ipcarg_t in_phone_hash; /**< Incoming phone hash. */ |
136 | link_t msg_queue; /**< Messages that should be delivered to this thread */ |
136 | link_t msg_queue; /**< Messages that should be delivered to this thread */ |
137 | /* Structures for connection opening packet */ |
137 | /* Structures for connection opening packet */ |
138 | ipc_callid_t callid; |
138 | ipc_callid_t callid; |
139 | ipc_call_t call; |
139 | ipc_call_t call; |
140 | ipc_callid_t close_callid; /* Identification of closing packet */ |
140 | ipc_callid_t close_callid; /* Identification of closing packet */ |
141 | void (*cthread)(ipc_callid_t,ipc_call_t *); |
141 | void (*cthread)(ipc_callid_t,ipc_call_t *); |
142 | } connection_t; |
142 | } connection_t; |
143 | 143 | ||
144 | /** Identifier of incoming connection handled by current thread */ |
144 | /** Identifier of incoming connection handled by current thread */ |
145 | __thread connection_t *PS_connection; |
145 | __thread connection_t *PS_connection; |