|
dev.gamez.lv Latvian Game Developers Community
|
View previous topic :: View next topic |
Author |
Message |
programmer
Joined: 15 Sep 2006 Posts: 71 Location: Latvija, Limbaži
|
Posted: 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 |
|
|
snake5 Indago dalībnieks
Joined: 27 Jun 2007 Posts: 2590
|
|
Back to top |
|
|
Vecais_Dumais_Laacis Guru
Joined: 29 Jan 2004 Posts: 800
|
Posted: 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 |
|
|
programmer
Joined: 15 Sep 2006 Posts: 71 Location: Latvija, Limbaži
|
Posted: Sun Jul 13, 2008 11:40 pm Post subject: |
|
Paldies Jums!
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.
P.S. Papētīju Boost bibliotēku, tā arī izskatās laba. |
|
Back to top |
|
|
|
|
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
|