[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Terminering af tråde



Hej

Det er et af de helt store problemer du har gang i og at terminere tråde
pænt kræver nok en hel del omkodning, hvis du har brugt blokerende IO.

Det pæneste vil være noget i stil med:

int running = 1;
void my_thread_method(void * ptr) {
    set_up_stuff();
    while (running) {
         do_stuff();
    }
    close_down_stuff();
}


...men det kræver at do_stuff() ikke blokerer. File descriptors (filer,
sockets, osv.) bør da konfigureres til at være non blocking eller du kan
bruge asynkron IO (aio_read, aio_write, osv.).
Jeg mener også, at man kan få read/write til at returnere efter et antal
millisekunder, men er ikke helt sikker på hvordan. Sikkert noget med
fcntl() eller lignende.


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2008-04-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *