It's possible? To return value use AsyncTask example: PHP: public function getCredits() : int { Server::getInstance()->getAsyncPool()->submitTask(new AsyncTask()); // return $value;}
"Async" by definition cannot return a value. Using this answer as a reference: https://stackoverflow.com/a/748189/3990767 The next line of code is executed before the async task finishes. Therefore, the result is not available when the next line is run. Therefore, classical getters cannot be achieved if the backend is async. Instead, the caller should pass a Closure into the getter, and the getter passes the Closure to the AsyncTask, which will call the closure when the data are ready. Several answers in this StackOverflow thread have excellent elaboration. See also https://github.com/SOF3/forums-comm...t-is-threading-does-it-make-the-server-faster