Mercurial > projects > ldc
comparison dmd/root/async.c @ 1587:def7a1d494fd
Merge DMD 1.051
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Fri, 06 Nov 2009 23:58:01 +0100 |
parents | e961851fb8be |
children |
comparison
equal
deleted
inserted
replaced
1586:7f728c52e63c | 1587:def7a1d494fd |
---|---|
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); |