MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

better fetch ordering

+36 -12
+3 -2
meson.build
··· 40 40 tlsuv_opts.add_cmake_defines({'BUILD_TESTING': 'OFF'}) 41 41 tlsuv_dep = cmake.subproject('tlsuv', options: tlsuv_opts).dependency('tlsuv') 42 42 43 + uthash_dep = subproject('uthash').get_variable('uthash_dep') 43 44 yyjson_dep = subproject('yyjson').get_variable('yyjson_dep') 44 45 uuidv7_dep = subproject('uuidv7').get_variable('uuidv7_dep') 45 46 mongoose_dep = subproject('mongoose').get_variable('mongoose_dep') ··· 66 67 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 67 68 68 69 version_conf = configuration_data() 69 - version_conf.set('ANT_VERSION', '0.0.6.22') 70 + version_conf.set('ANT_VERSION', '0.0.6.23') 70 71 version_conf.set('ANT_GIT_HASH', git_hash) 71 72 version_conf.set('ANT_BUILD_DATE', build_date) 72 73 ··· 108 109 tlsuv_dep, libsodium_dep, 109 110 yyjson_dep, minicoro_dep, 110 111 uuidv7_dep, openssl_dep, 111 - zlib_dep 112 + zlib_dep, uthash_dep 112 113 ] 113 114 114 115 if host_machine.system() == 'darwin'
+2
src/ant.c
··· 481 481 482 482 if (!has_pending_microtasks() && !has_pending_timers() && !has_pending_coroutines() && !has_pending_fetches()) break; 483 483 } 484 + 485 + js_poll_events(js); 484 486 } 485 487 486 488 static jsval_t start_async_in_coroutine(struct js *js, const char *code, size_t code_len, jsval_t closure_scope) {
+18 -10
src/modules/fetch.c
··· 4 4 #include <string.h> 5 5 #include <tlsuv/tlsuv.h> 6 6 #include <tlsuv/http.h> 7 + #include <utarray.h> 8 + #include <unistd.h> 7 9 8 10 #include "runtime.h" 9 11 #include "modules/fetch.h" ··· 26 28 int failed; 27 29 char *error_msg; 28 30 jsval_t headers_obj; 29 - struct fetch_request_s *next; 30 31 } fetch_request_t; 31 32 32 33 static uv_loop_t *fetch_loop = NULL; 33 - static fetch_request_t *pending_requests = NULL; 34 + static UT_array *pending_requests = NULL; 34 35 35 36 static void free_fetch_request(fetch_request_t *req) { 36 37 if (!req) return; ··· 42 43 } 43 44 44 45 static void remove_pending_request(fetch_request_t *req) { 45 - fetch_request_t **curr = &pending_requests; 46 - while (*curr) { 47 - if (*curr == req) *curr = req->next; break; 48 - curr = &(*curr)->next; 46 + if (!req || !pending_requests) return; 47 + 48 + fetch_request_t **p = NULL; 49 + unsigned int i = 0; 50 + 51 + while ((p = (fetch_request_t**)utarray_next(pending_requests, p))) { 52 + if (*p == req) { utarray_erase(pending_requests, i, 1); break; } 53 + i++; 49 54 } 50 55 } 51 56 ··· 187 192 return js_mkundef(); 188 193 } 189 194 190 - req->next = pending_requests; 191 - pending_requests = req; 195 + if (!pending_requests) utarray_new(pending_requests, &ut_ptr_icd); 196 + utarray_push_back(pending_requests, &req); 192 197 193 198 struct tlsuv_url_s parsed_url; 194 199 if (tlsuv_parse_url(&parsed_url, url_str) != 0) { ··· 316 321 } 317 322 318 323 int has_pending_fetches(void) { 319 - return pending_requests != NULL || (fetch_loop && uv_loop_alive(fetch_loop)); 324 + return (pending_requests && utarray_len(pending_requests) > 0) || (fetch_loop && uv_loop_alive(fetch_loop)); 320 325 } 321 326 322 327 void fetch_poll_events(void) { 323 - if (fetch_loop && uv_loop_alive(fetch_loop)) uv_run(fetch_loop, UV_RUN_ONCE); 328 + if (fetch_loop && uv_loop_alive(fetch_loop)) { 329 + uv_run(fetch_loop, UV_RUN_ONCE); 330 + if (pending_requests && utarray_len(pending_requests) > 0) usleep(1000); 331 + } 324 332 }
+13
subprojects/uthash.wrap
··· 1 + [wrap-file] 2 + directory = uthash-2.3.0 3 + source_url = https://github.com/troydhanson/uthash/archive/v2.3.0.tar.gz 4 + source_filename = uthash-2.3.0.tar.gz 5 + source_hash = e10382ab75518bad8319eb922ad04f907cb20cccb451a3aa980c9d005e661acc 6 + source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/uthash_2.3.0-2/uthash-2.3.0.tar.gz 7 + patch_filename = uthash_2.3.0-2_patch.zip 8 + patch_url = https://wrapdb.mesonbuild.com/v2/uthash_2.3.0-2/get_patch 9 + patch_hash = d66806488ebd37246a160f62779e3eb3259b8cd35a978f7499daa0390923cd99 10 + wrapdb_version = 2.3.0-2 11 + 12 + [provide] 13 + dependency_names = uthash