Changeset 58 for Include/Classes/System/Threading
- Timestamp:
- Jan 12, 2007, 3:21:30 AM (18 years ago)
- Location:
- Include/Classes/System/Threading
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Threading/Thread.ab
r42 r58 1 1 'threading.sbp 2 2 3 4 '-------------------------------------------------------------------- 5 ' スレッドの優先順位 6 '-------------------------------------------------------------------- 3 7 Enum ThreadPriority 4 8 Highest = 2 … … 11 15 TypeDef PTHREAD_START_ROUTINE = *Function(args As VoidPtr) As DWord 12 16 17 18 '-------------------------------------------------------------------- 19 ' スレッド クラス 20 '-------------------------------------------------------------------- 13 21 Class Thread 14 22 m_hThread As HANDLE … … 19 27 m_fp As PTHREAD_START_ROUTINE 20 28 m_args As VoidPtr 29 21 30 Public 22 31 Sub Thread() … … 137 146 Return GetThreadContext(m_hThread,Context) 138 147 End Function 148 Function __SetContext(ByRef Context As CONTEXT) As BOOL 149 Return SetThreadContext(m_hThread,Context) 150 End Function 139 151 140 152 … … 147 159 148 160 149 'すべてのスレッドの管理 161 '-------------------------------------------------------------------- 162 ' すべてのスレッドの管理 163 '-------------------------------------------------------------------- 164 ' TODO: このクラスをシングルトンにする 150 165 Class _System_CThreadCollection 151 166 Public … … 159 174 ppobj_Thread=HeapAlloc(_System_hProcessHeap,0,1) 160 175 pStackBase=HeapAlloc(_System_hProcessHeap,0,1) 176 ppException=HeapAlloc(_System_hProcessHeap,0,1) 161 177 ThreadNum=0 162 178 … … 175 191 pStackBase=0 176 192 193 HeapFree(_System_hProcessHeap,0,ppException) 194 ppException = 0 195 177 196 ThreadNum=0 178 197 … … 185 204 EnterCriticalSection(CriticalSection) 186 205 206 'スレッドオブジェクトを生成 187 207 Dim pobj_NewThread As *Thread 188 208 pobj_NewThread=New Thread(obj_Thread) 189 209 210 '例外処理管理用オブジェクトを生成 211 Dim pException As *ExceptionService 212 pException = New ExceptionService 213 190 214 Dim i As Long 191 215 For i=0 To ELM(ThreadNum) 192 If ppobj_Thread[i]=0 Then 193 ppobj_Thread[i]=pobj_NewThread 194 pStackBase[i]=NowSp 216 If ppobj_Thread[i] = 0 Then 217 ppobj_Thread[i] = pobj_NewThread 218 pStackBase[i] = NowSp 219 ppException[i] = pException 195 220 Exit For 196 221 End If 197 222 Next 198 223 199 If i =ThreadNum Then224 If i = ThreadNum Then 200 225 ppobj_Thread=HeapReAlloc(_System_hProcessHeap,0,ppobj_Thread,(ThreadNum+1)*SizeOf(*Thread)) 201 226 ppobj_Thread[ThreadNum]=pobj_NewThread 202 227 pStackBase=HeapReAlloc(_System_hProcessHeap,0,pStackBase,(ThreadNum+1)*SizeOf(LONG_PTR)) 203 228 pStackBase[ThreadNum]=NowSp 229 ppException=HeapReAlloc(_System_hProcessHeap,0,ppException,(ThreadNum+1)*SizeOf(*ExceptionService)) 230 ppException[ThreadNum]=pException 204 231 ThreadNum++ 205 232 End If … … 242 269 End Sub 243 270 244 271 'カレントスレッドを取得 245 272 Function CurrentThread(ByRef obj_Thread As Thread) As BOOL 246 273 Dim dwNowThreadId As DWord … … 257 284 Return 0 258 285 End Function 286 287 288 Private 289 '------------------------------------------ 290 ' スレッド固有の例外処理制御 291 '------------------------------------------ 292 ppException As **ExceptionService 293 294 Public 295 Function GetCurrentException() As *ExceptionService 296 Dim dwNowThreadId As DWord 297 dwNowThreadId=GetCurrentThreadId() 298 299 Dim i As Long 300 For i=0 To ELM(ThreadNum) 301 If ppobj_Thread[i]->ThreadId=dwNowThreadId Then 302 Return ppException[i] 303 End If 304 Next 305 306 Return NULL 307 End Function 259 308 End Class 260 309 Dim _System_pobj_AllThreads As *_System_CThreadCollection -
Include/Classes/System/Threading/WaitHandle.ab
r47 r58 99 99 ExitThread(0) 100 100 End Select 101 End Sub101 End Function 102 102 End Class 103 103
Note:
See TracChangeset
for help on using the changeset viewer.