Added more report output to the kernel driver loading code. Hopefully this helps to find the problems in Issue 253.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2011 Michael Möller <mmoeller@openhardwaremonitor.org>
12 using System.Collections;
13 using System.Collections.Generic;
15 namespace OpenHardwareMonitor.Collections {
16 public class RingCollection<T> : IEnumerable<T> {
20 // first item of collection
23 // index after the last item of the collection
26 // number of items in the collection
29 public RingCollection() : this(0) { }
31 public RingCollection(int capacity) {
33 throw new ArgumentOutOfRangeException("capacity");
34 this.array = new T[capacity];
45 T[] newArray = new T[value];
48 Array.Copy(array, head, newArray, 0, size);
50 Array.Copy(array, head, newArray, 0, array.Length - head);
51 Array.Copy(array, 0, newArray, array.Length - head, tail);
54 this.array = newArray;
56 this.tail = size == value ? 0 : size;
62 // remove potential references
64 Array.Clear(array, head, size);
66 Array.Clear(array, 0, tail);
67 Array.Clear(array, head, array.Length - head);
75 public void Append(T item) {
76 if (size == array.Length) {
77 int newCapacity = array.Length * 3 / 2;
78 if (newCapacity < array.Length + 8)
79 newCapacity = array.Length + 8;
80 Capacity = newCapacity;
84 tail = tail + 1 == array.Length ? 0 : tail + 1;
90 throw new InvalidOperationException();
92 T result = array[head];
93 array[head] = default(T);
94 head = head + 1 == array.Length ? 0 : head + 1;
106 public T this[int index] {
108 if (index < 0 || index >= size)
109 throw new IndexOutOfRangeException();
110 int i = head + index;
111 if (i >= array.Length)
116 if (index < 0 || index >= size)
117 throw new IndexOutOfRangeException();
118 int i = head + index;
119 if (i >= array.Length)
128 throw new InvalidOperationException();
133 throw new InvalidOperationException();
141 throw new InvalidOperationException();
142 return array[tail == 0 ? array.Length - 1 : tail - 1];
146 throw new InvalidOperationException();
147 array[tail == 0 ? array.Length - 1 : tail - 1] = value;
151 IEnumerator<T> IEnumerable<T>.GetEnumerator() {
152 return new RingCollection<T>.Enumerator(this);
155 IEnumerator IEnumerable.GetEnumerator() {
156 return new RingCollection<T>.Enumerator(this);
159 private struct Enumerator : IEnumerator<T>, IEnumerator {
161 private RingCollection<T> collection;
164 public Enumerator(RingCollection<T> collection) {
165 this.collection = collection;
169 public void Dispose() {
173 public void Reset() {
180 throw new InvalidOperationException();
181 return collection[index];
185 object IEnumerator.Current {
188 throw new InvalidOperationException();
189 return collection[index];
193 public bool MoveNext() {
199 if (index == collection.size) {