Changeset 58 for Include/Classes/System
- Timestamp:
- Jan 12, 2007, 3:21:30 AM (18 years ago)
- Location:
- Include/Classes/System
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Diagnostics/Trace.ab
r45 r58 1 1 2 ' リスナ3 Class TraceListener4 End Class5 2 6 3 ' リスナコレクション 7 4 Class TraceListenerCollection 5 ppListeners As **TraceListener 6 count As Long 8 7 Public 8 9 Sub TraceListenerCollection() 10 ppListeners = _System_malloc( 1 ) 11 End Sub 12 Sub ~TraceListenerCollection() 13 Dim i As Long 14 For i = 0 To ELM( count ) 15 Delete ppListeners[i] 16 Next 17 _System_free( ppListeners ) 18 End Sub 9 19 10 20 '---------------------------------------------------------------- … … 13 23 14 24 ' リスナを追加 15 Function Add( listener As TraceListener ) 16 ' TODO: 実装 17 End Function 25 Sub Add( listener As TraceListener ) As Long 26 ppListeners = _System_realloc( ppListeners, ( count + 1 ) * SizeOf( *TraceListener ) ) 27 ppListeners[count] = New TraceListener( listener ) 28 count++ 29 End Sub 18 30 19 31 ' 複数のリスナを追加 20 32 Sub AddRange( listeners As TraceListenerCollection ) 21 33 ' TODO: 実装 22 End Function34 End Sub 23 35 24 36 ' リストからすべてのリスナを削除 … … 50 62 '---------------------------------------------------------------- 51 63 64 ' インデクサ ( Getter ) 65 Function Operator[] ( index As Long ) As TraceListener 66 If index < 0 or count <= index Then 67 ' TODO: エラー処理 68 debug 69 End If 70 71 Dim tempListener As TraceListener( ByVal ppListeners[index] ) 72 Return tempListener 73 End Function 74 52 75 ' 保有するリスナの数を取得する 53 76 Function Count() As Long 54 ' TODO: 実装 55 End Function 56 57 ' リスナを取得する 58 Function Item( index As Long ) As TraceListener 59 ' TODO: 実装 77 Return count 60 78 End Function 61 79 End Class … … 65 83 Static indentSize = 4 As Long 66 84 67 Static Function GetIndentString() As String68 Dim i As Long69 85 70 Dim IndentStr = "" 71 For i = 0 To ELM( indentSize ) 72 IndentStr = IndentStr + " " 73 Next 74 75 Dim ResultStr = "" 76 For i = 0 To ELM( indentLevel ) 77 ResultStr = ResultStr + IndentStr 78 Next 79 80 Return ResultStr 81 End Function 86 ' リスナ管理 87 Static Listeners As TraceListenerCollection 82 88 83 89 Public … … 113 119 ' インデントレベルを上げる 114 120 Static Sub Indent() 115 indentLevel++121 IndentLevel = indentLevel + 1 116 122 End Sub 117 123 … … 122 128 Return 123 129 End If 124 indentLevel-- 130 IndentLevel = indentLevel - 1 131 End Sub 132 133 Static Sub Write( message As String ) 134 125 135 End Sub 126 136 127 137 ' 一行の文字列を出力 128 138 Static Sub WriteLine( message As String ) 129 Dim tempmsg = GetIndentString() + message + Ex"\n" 130 131 ' TODO: リスナへの出力を実装 139 Dim i As Long 140 For i = 0 To ELM( Listeners.Count ) 141 Dim temp As TraceListener 142 temp = Listeners[i] 143 temp.WriteLine( message ) 144 Next 132 145 End Sub 133 146 … … 141 154 Return indentLevel 142 155 End Function 143 Static Sub IndentLevel( level As Long ) 144 indentLevel = level 156 Static Sub IndentLevel( indentLevel As Long ) 157 This.indentLevel = indentLevel 158 159 Dim i As Long 160 For i = 0 To ELM( Listeners.Count ) 161 Dim temp As TraceListener 162 temp = Listeners[i] 163 temp.IndentLevel = indentLevel 164 Next 145 165 End Sub 146 166 … … 151 171 Static Sub IndentSize( size As Long ) 152 172 indentSize = size 153 End Sub154 173 155 ' Listenersプロパティ156 Static Function Listeners() As TraceListenerCollection157 Return listeners158 End Function159 Static Sub Listeners( listeners As TraceListenerCollection )160 This.listeners = listeners174 Dim i As Long 175 For i = 0 To ELM( Listeners.Count ) 176 Dim temp As TraceListener 177 temp = Listeners[i] 178 temp.IndentSize = indentSize 179 Next 161 180 End Sub 162 181 -
Include/Classes/System/Object.ab
r51 r58 1 1 Class Object 2 2 Public 3 4 Sub Object() 5 End Sub 6 Sub ~Object() 7 End Sub 3 8 4 9 ' 2つのオブジェクトが等しいかどうかを判断する -
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.