10using System.Threading;
32 Thread consumer =
new Thread(
new ThreadStart(consumerThread));
33 Thread producer =
new Thread(
new ThreadStart(producerThread));
42 private void consumerThread() {
44 for (
int i = 0; i < buffer.
Capacity; i++) {
47 s.name = i.ToString();
50 }
catch (Exception e) {
51 Assert.Fail(e.Message);
55 private void producerThread() {
57 for (
int i = 0; i < buffer.
Capacity; i++) {
61 Assert.That(s.index, Is.EqualTo(i));
62 Assert.That(s.name, Is.EqualTo(i.ToString()));
64 }
catch (Exception e) {
65 Assert.Fail(e.Message);
69 private struct TestStruct {
int Capacity
Returns the maximum number of elements that the buffer can hold.
bool TryEnqueue(ref T t)
Tries to enqueue a value into the buffer. If the buffer is already full, this method will perform no ...
bool TryDequeue(out T t)
Tries to dequeue a value off of the buffer. If the buffer is empty this method will perform no action...