comparison dmd2/root/async.c @ 1526:54b3c1394d62

Merged dmdfe 2.031.
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 07 Jul 2009 02:26:11 +0100
parents 638d16625da2
children
comparison
equal deleted inserted replaced
1525:d28cd7c45267 1526:54b3c1394d62
59 filesdim++; 59 filesdim++;
60 } 60 }
61 61
62 void AsyncRead::start() 62 void AsyncRead::start()
63 { 63 {
64 unsigned threadaddr; 64 //printf("aw->filesdim = %p %d\n", this, filesdim);
65 hThread = (HANDLE) _beginthreadex(NULL, 65 if (filesdim)
66 0, 66 {
67 &startthread, 67 unsigned threadaddr;
68 this, 68 hThread = (HANDLE) _beginthreadex(NULL,
69 0, 69 0,
70 (unsigned *)&threadaddr); 70 &startthread,
71 this,
72 0,
73 (unsigned *)&threadaddr);
71 74
72 if (hThread) 75 if (hThread)
73 { 76 {
74 SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST); 77 SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST);
75 } 78 }
76 else 79 else
77 { 80 {
78 assert(0); 81 assert(0);
82 }
79 } 83 }
80 } 84 }
81 85
82 int AsyncRead::read(size_t i) 86 int AsyncRead::read(size_t i)
83 { 87 {
96 100
97 unsigned __stdcall startthread(void *p) 101 unsigned __stdcall startthread(void *p)
98 { 102 {
99 AsyncRead *aw = (AsyncRead *)p; 103 AsyncRead *aw = (AsyncRead *)p;
100 104
105 //printf("aw->filesdim = %p %d\n", aw, aw->filesdim);
101 for (size_t i = 0; i < aw->filesdim; i++) 106 for (size_t i = 0; i < aw->filesdim; i++)
102 { FileData *f = &aw->files[i]; 107 { FileData *f = &aw->files[i];
103 108
104 f->result = f->file->read(); 109 f->result = f->file->read();
105 SetEvent(f->event); 110 SetEvent(f->event);