- Timestamp:
- Mar 11, 2007, 4:51:49 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Threading/Thread.ab
r58 r148 22 22 m_hThread As HANDLE 23 23 m_dwThreadId As DWord 24 25 24 m_Priority As ThreadPriority 26 25 … … 56 55 m_hThread=hThread 57 56 m_dwThreadId=dwThreadId 58 m_Priority=ThreadPriority.Normal59 57 End Sub 60 58 … … 107 105 108 106 'GCにスレッド開始を通知 109 _System_pobj_AllThreads->BeginThread( This,_System_GetSp() As *LONG_PTR)107 _System_pobj_AllThreads->BeginThread(VarPtr(This),_System_GetSp() As *LONG_PTR) 110 108 111 109 … … 121 119 122 120 'GCにスレッド終了を通知 123 _System_pobj_AllThreads->EndThread( This)121 _System_pobj_AllThreads->EndThread(VarPtr(This)) 124 122 125 123 '自身のスレッドハンドルを閉じる … … 137 135 138 136 Sub Suspend() 139 SuspendThread(m_hThread) 137 If SuspendThread(m_hThread) = &HFFFFFFFF Then 138 debug 139 End If 140 140 End Sub 141 141 Sub Resume() 142 ResumeThread(m_hThread) 142 If ResumeThread(m_hThread) = &HFFFFFFFF Then 143 debug 144 End If 143 145 End Sub 144 146 … … 172 174 173 175 Sub _System_CThreadCollection() 174 ppobj_Thread= HeapAlloc(_System_hProcessHeap,0,1)176 ppobj_Thread=GC_malloc(1) 175 177 pStackBase=HeapAlloc(_System_hProcessHeap,0,1) 176 178 ppException=HeapAlloc(_System_hProcessHeap,0,1) … … 182 184 183 185 Sub ~_System_CThreadCollection() 184 End Sub185 186 Sub Finalize()187 HeapFree(_System_hProcessHeap,0,ppobj_Thread)188 ppobj_Thread=0189 190 186 HeapFree(_System_hProcessHeap,0,pStackBase) 191 187 pStackBase=0 … … 201 197 202 198 'スレッドを生成 203 Sub BeginThread( ByRef obj_Thread AsThread,NowSp As *LONG_PTR)199 Sub BeginThread(pThread As *Thread,NowSp As *LONG_PTR) 204 200 EnterCriticalSection(CriticalSection) 205 206 'スレッドオブジェクトを生成207 Dim pobj_NewThread As *Thread208 pobj_NewThread=New Thread(obj_Thread)209 201 210 202 '例外処理管理用オブジェクトを生成 … … 215 207 For i=0 To ELM(ThreadNum) 216 208 If ppobj_Thread[i] = 0 Then 217 ppobj_Thread[i] = p obj_NewThread209 ppobj_Thread[i] = pThread 218 210 pStackBase[i] = NowSp 219 211 ppException[i] = pException … … 223 215 224 216 If i = ThreadNum Then 225 ppobj_Thread= HeapReAlloc(_System_hProcessHeap,0,ppobj_Thread,(ThreadNum+1)*SizeOf(*Thread))226 ppobj_Thread[ThreadNum]=p obj_NewThread217 ppobj_Thread=realloc(ppobj_Thread,(ThreadNum+1)*SizeOf(*Thread)) 218 ppobj_Thread[ThreadNum]=pThread 227 219 pStackBase=HeapReAlloc(_System_hProcessHeap,0,pStackBase,(ThreadNum+1)*SizeOf(LONG_PTR)) 228 220 pStackBase[ThreadNum]=NowSp … … 235 227 236 228 'スレッドを終了 237 Sub EndThread( ByRef obj_Thread AsThread)229 Sub EndThread(pThread As *Thread) 238 230 EnterCriticalSection(CriticalSection) 239 231 Dim i As Long 240 232 For i=0 To ELM(ThreadNum) 241 If ppobj_Thread[i]->Equals(obj_Thread) Then 242 Delete ppobj_Thread[i] 233 If ppobj_Thread[i] = pThread Then 234 If i = 0 Then 235 Delete pThread 236 End If 243 237 ppobj_Thread[i]=0 244 238 pStackBase[i]=0 … … 269 263 End Sub 270 264 265 ' 自分以外のスレッドを中断 266 Sub SuspendAnotherThread() 267 Dim currentThread = Thread.CurrentThread() 268 269 Dim i As Long 270 For i=0 To ELM(ThreadNum) 271 272 If currentThread.Equals( ByVal ppobj_Thread[i] ) Then 273 Continue 274 End If 275 276 If ppobj_Thread[i] Then 277 ppobj_Thread[i]->Suspend() 278 End If 279 Next 280 End Sub 281 282 ' 自分以外のスレッドを再開 283 Sub ResumeAnotherThread() 284 Dim currentThread = Thread.CurrentThread() 285 286 Dim i As Long 287 For i=0 To ELM(ThreadNum) 288 289 If currentThread.Equals( ByVal ppobj_Thread[i] ) Then 290 Continue 291 End If 292 293 If ppobj_Thread[i] Then 294 ppobj_Thread[i]->Resume() 295 End If 296 Next 297 End Sub 298 271 299 'カレントスレッドを取得 272 300 Function CurrentThread(ByRef obj_Thread As Thread) As BOOL
Note:
See TracChangeset
for help on using the changeset viewer.