Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (Grant), 999 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 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: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
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 | chip programmers | 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