Gamestudio Links
Zorro Links
Newest Posts
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
Zorro version 3.0 prerelease!
by TipmyPip. 02/24/26 17:09
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (Martin_HH, TipmyPip, AndrewAMD, Grant, USER0328), 5,287 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problem reading data from file with max. speed #381482
08/28/11 19:28
08/28/11 19:28
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi,

I'm using a code similiar to the following to read data from a file:

Code:
while (file_str_read(fhandle,objName) != -1) {
file_str_read(fhandle,str);
addToDynamicGSHashmap(soundsMap, _chr(objName), str_create(str));
file_str_read(fhandle,str); // read ending *
wait(1);
}



As it is a lot of data to read an animated loading screen is displayed.

The problem is that the wait(1) is FPS dependend. In window mode the reading of the data lasts about 25 seconds (using fps_max = 0).
In fullscreen mode it lasts nearly 2 minutes as the framerate is synchronized to 60 fps.

A wait(-0.01) is also too slow.

So what's the best way to read the data from file at maximum speed non-blocking?

I'd like to avoid doing a wait only every x times during the loop.

Regards,
Pegamode.


Re: problem reading data from file with max. speed [Re: pegamode] #381485
08/28/11 20:39
08/28/11 20:39
Joined: Jul 2008
Posts: 894
T
TechMuc Offline
User
TechMuc  Offline
User
T

Joined: Jul 2008
Posts: 894
create a different thread for loading the file.

see:
http://msdn.microsoft.com/en-us/library/kdzttdcb(v=vs.80).aspx
http://simplesamples.info/Windows/_beginthreadex.php

Re: problem reading data from file with max. speed [Re: TechMuc] #381537
08/29/11 11:19
08/29/11 11:19
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
A different thread is an overkill. Reducing the number of wait(1) calls, what you'd like to avoid, is the best and simplest solution here.

Re: problem reading data from file with max. speed [Re: jcl] #381549
08/29/11 12:50
08/29/11 12:50
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Ok ... I thought that reducing the number of wait calls wouldn't be a good coding style, because between the wait calls my code blocks everything else.

I'll reduce the number of waits. Thanks for the answers.


Moderated by  old_bill, Tobias 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1