Hi, I'm working with asynchttpserver and I found that I can not access global variables from within the server callback.
This seems to be because the server requires a {.gcsafe.} callback, and if a global variable (in this case a table) is accessed from within the callback it is no longer gc safe.
Adding the {.threadvar.} pragma to the global variable fixed the error, but I don't know why. So:
Thanks.
As you noted, the stdlib asynchttpserver is not multi-threaded, but httpbeast is multithreaded.
But, both libraries use the same core stdlib asyncdispatch (they were written by the same author @dom96).
asyncdispatch supports both single threaded and multi-threaded environments. This is why the {.gcsafe.} is required.