Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: public TThread problem when loading data from hdd


This question is answered.


Permlink Replies: 2 - Last Post: Sep 15, 2014 1:20 PM Last Post By: Cezary Ziąber
Cezary Ziąber

Posts: 9
Registered: 10/14/14
public TThread problem when loading data from hdd  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 14, 2014 6:53 AM
Hello, everyone i'm new to the forum i wanted to ask about TThread that is:
I am currently loading image heightmap data from NASA within a TThread, thus its a huge amount of data (for my model it could be no less than 100GB) i sliced it to the smaller fragments, each time i change position (by 30 km) i load new heightmap data, and the problem occurs it looks like theres no threaded loading, (i mean programm stalls until models are loaded - and i use TTHread because i didint want my programm to freeze during this process), maybe its because i use old notebook (havent tested it yet on faster PCs).

Ok so the code looks like this:

class TEarthHDetailLoader : public TThread {
public:
TGLModel * model[9];
__fastcall TEarthHDetailLoader(bool CreateSuspended);
__fastcall ~TEarthHDetailLoader();
void __fastcall Execute();
TGLModel * __fastcall Create_hdetail_region(int x, int y, AnsiString sector);
void __fastcall CheckIfCameraMovedToDifferentSector(int x, int y);

};


The thing is i do not call loading models from a switch defined in Execute ( you know while(!Terminated) { if (loadmodels == true) { loadmodels(); } }

i just call CheckIfCameraMovedToDifferentSector(int x, int y); from outside of thread

Would anyone point me in the right direction of doing this? or just tell me if i am doing it right but yeah my pc is too slow to load it without program freeze :P

Cheers.

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: public TThread problem when loading data from hdd
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 14, 2014 9:33 AM   in response to: Cezary Ziąber in response to: Cezary Ziąber
Cezary wrote:

i just call CheckIfCameraMovedToDifferentSector(int x, int y); from
outside of thread

That is your mistake. You MUST call it from inside of Execute(), eg:

class TEarthHDetailLoader : public TThread
{
private:
    int x;
    int y;
    void __fastcall CheckIfCameraMovedToDifferentSector(int x, int y);
    //...
protected:
    void __fastcall Execute();
public:
    __fastcall TEarthHDetailLoader(int aX, int aY);
    __fastcall ~TEarthHDetailLoader();
    //...
};


__fastcall TEarthHDetailLoader::TEarthHDetailLoader(int aX, int aY)
    : TThread(false)
{
    x = aX;
    y = aY;
    //...
}
 
__fastcall TEarthHDetailLoader::~TEarthHDetailLoader()
{
    //...
}
 
void __fastcall TEarthHDetailLoader::Execute()
{
    //...
    CheckIfCameraMovedToDifferentSector(x, y);
    //...
}
 
void __fastcall TEarthHDetailLoader::CheckIfCameraMovedToDifferentSector(int 
x, int y)
{
    if (Terminated)
        return;
 
    // load some data...
 
    if (Terminated)
        return;
 
    // load some data...
 
    // etc...
}


--
Remy Lebeau (TeamB)
Cezary Ziąber

Posts: 9
Registered: 10/14/14
Re: public TThread problem when loading data from hdd  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 15, 2014 1:20 PM   in response to: Cezary Ziąber in response to: Cezary Ziąber
Thanks for the reply however i didint check it (i don't have time for it) i know it will work, (i just forgot how to use TThread)

Thanks again.

Cheers.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02