Hello, I've set up tora to run as fcgi on an nginx server on
digitalocean.com.
The tora version used is the github latest version.
Haxe is 3.2.1 using apt-get.
I have some questions regarding the workings of tora.
1. Why does the following code display all at once (after a 10s delay) instead of showing each number one at a time per second?
import neko.Lib;
import neko.Web;
class Index
{
public static var count:Int = 0;
public static function main():Void
{
Web.cacheModule(start);
start();
}
public static function start():Void
{
Web.setHeader("Content-Type", "text/plain");
Sys.println('Hello World! count: $count, is tora: ${Web.isTora}');
for (i in 0...10)
{
Sys.println('$i');
Web.flush(); // flush isn't working?
Sys.sleep(1);
}
Sys.println('done! count: $count');
++count;
}
}
flush is supposed to flush the buffer to the browser? You can see the output at
http://www.moonaire.com
2. I'd also like to understand tora's concurrency. It's multi-threaded right? And I assume it's from a pool of x threads. But from online articles, it mentioned that cacheModule will keep a single instance of my above program (making that static count variable work)... so for my above program, it becomes single threaded again? So if I happen to have some slower codes, it'll block for all visitors to the website?
The above program is also meant to test that. I opened 2 tabs, and went to
www.moonaire.com on each, about a second apart. The first tab loads in about 10s, which is expected. The second tab loads 10s after the first tab has loaded, bringing the duration to about 21s.
How does the multi-threading work?
Thanks in advance for any explanations.