dev.gamez.lv Forum Index dev.gamez.lv
Latvian Game Developers Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 

Datu saņemšana caur netu, "neiesaldējot" visu p

 
dev.gamez.lv Forum Index -> Programmēšana
View previous topic :: View next topic  
Author Message
programmer



Joined: 15 Sep 2006
Posts: 71
Location: Latvija, Limbaži

PostPosted: Sat Jul 12, 2008 8:47 pm    Post subject: Datu saņemšana caur netu, "neiesaldējot" visu p

Veidoju programmu, kurai dažreiz no interneta jāielādē daži faili. Problēma ir tāda, ka visa programma "nofrīzojas", kamēr darbojas download funkcija. Tas ir pašsaprotami. Taču, man vajag, lai programmas GUI strādātu arī pa to laiku, kamēr tas fails ielādējas.
Es saprotu, ka viens no risinājumiem ir laist download funkciju citā pavedienā. Šī programma būs domāta vairākām platformām (vismaz win un linux). Meklēju kādu portējamu bibliotēku darbībām ar pavedieniem, taču neatradu. Šķiet, ka tādas vispār neeksistē.
Uzklausīšu jūsu viedokli, ko darīt šādā gadījumā?
Back to top
View user's profile Visit poster's website
snake5
Indago dalībnieks
Indago dalībnieks


Joined: 27 Jun 2007
Posts: 2590

PostPosted: Sat Jul 12, 2008 9:03 pm    Post subject:

varbūt der boost?
http://www.boost.org/
http://www.boost.org/doc/libs/1_35_0/doc/html/thread.html
_________________
"There are two choices here: "looks good" and "realism"." -- Paul Nettle
Back to top
View user's profile Visit poster's website
Vecais_Dumais_Laacis
Guru
Guru


Joined: 29 Jan 2004
Posts: 800

PostPosted: Sat Jul 12, 2008 10:01 pm    Post subject:

nav gan labaakais piemeers (peec standartiem/shmandartiem)
bet es taa lietoju un nesuudzos

Code:
#ifndef _WIN32
   #include <pthread.h>
   #define _beginthread(func, stack, data) pthread_create(&glob_hack_tid, NULL, (void*(*)(void*))func, data)
   static pthread_t glob_hack_tid;
   #define Sleep(x) usleep((x)*1000);
#else
   #include <process.h>
#endif


un izmantojam

Code:
void SomeThread(void *dummy)
{
 DoSomeMagick();
}

int main()
{
 _beginthread(SomeThread, 0, NULL);
 while(true) Sleep(1000);
}


man gan threadi nav paredzeeti ka beigsies kaadreiz - attieciigi netiek saglabaati threadid kuru nocloseet veelaak


btw pthreads ir arii win32 porteets - iespeejams var prosta threadus pthreados kodeet un tad izmantot uz visaam os kas pthreadus supportee
_________________
...un ja bites buutu laachi...
Back to top
View user's profile
programmer



Joined: 15 Sep 2006
Posts: 71
Location: Latvija, Limbaži

PostPosted: Sun Jul 13, 2008 11:40 pm    Post subject:

Paldies Jums! Smile
Es nesaprotu, kā es šitos neatradu. Uzdūros tikai POSIX Threadiem, kur nebija minēts nekas par win32 portu.
Novilku pthreads-win32, pamēģināju - viss kā nākas. Izskatās, ka lietošu šo arī turpmāk. Smile
P.S. Papētīju Boost bibliotēku, tā arī izskatās laba.
Back to top
View user's profile Visit poster's website
Display posts from previous:   
dev.gamez.lv Forum Index -> Programmēšana All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group