File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,8 @@ namespace async_postgres {
136
136
void process_notifications (GLua::ILuaInterface* lua, Connection* state);
137
137
138
138
// query.cpp
139
+ void process_result (GLua::ILuaInterface* lua, Connection* state,
140
+ pg::result&& result);
139
141
void process_query (GLua::ILuaInterface* lua, Connection* state);
140
142
141
143
// result.cpp
Original file line number Diff line number Diff line change @@ -200,6 +200,33 @@ namespace async_postgres::lua {
200
200
201
201
return 0 ;
202
202
}
203
+
204
+ lua_protected_fn (wait) {
205
+ lua->CheckType (1 , async_postgres::connection_meta);
206
+
207
+ auto state = lua_connection_state ();
208
+ if (state->query ) {
209
+ auto & query = state->query .value ();
210
+
211
+ // if query wasn't sent, send in through process_query
212
+ if (!query.sent ) {
213
+ async_postgres::process_query (lua, state);
214
+ }
215
+
216
+ // while query is the same and it's not done
217
+ while (state->query .has_value () &&
218
+ &query == &state->query .value ()) {
219
+ async_postgres::process_result (lua, state,
220
+ pg::getResult (state->conn ));
221
+ }
222
+
223
+ lua->PushBool (true );
224
+ return 1 ;
225
+ }
226
+
227
+ lua->PushBool (false );
228
+ return 1 ;
229
+ }
203
230
} // namespace async_postgres::lua
204
231
205
232
#define register_lua_fn (name ) \
@@ -221,6 +248,7 @@ void register_connection_mt(GLua::ILuaInterface* lua) {
221
248
register_lua_fn (describePortal);
222
249
register_lua_fn (reset);
223
250
register_lua_fn (setNotifyCallback);
251
+ register_lua_fn (wait);
224
252
225
253
async_postgres::register_misc_connection_functions (lua);
226
254
Original file line number Diff line number Diff line change @@ -92,8 +92,8 @@ inline bool poll_query(PGconn* conn, Query& query) {
92
92
return true ;
93
93
}
94
94
95
- void process_result (GLua::ILuaInterface* lua, Connection* state,
96
- pg::result&& result) {
95
+ void async_postgres:: process_result (GLua::ILuaInterface* lua, Connection* state,
96
+ pg::result&& result) {
97
97
// query is done
98
98
if (!result) {
99
99
state->query .reset ();
You can’t perform that action at this time.
0 commit comments