summaryrefslogtreecommitdiff
path: root/Chalice/src/Chalice.cs
diff options
context:
space:
mode:
authorGravatar jansmans <unknown>2009-08-17 12:21:15 +0000
committerGravatar jansmans <unknown>2009-08-17 12:21:15 +0000
commit3fd9f0a2a4f754c039653ac2fab090167f0b2596 (patch)
tree51e8cb2fa4fcb76771c037ddba752d8ae66e4e58 /Chalice/src/Chalice.cs
parent4d3e9b8f2bdb29ec53d1c418a11501bcf6a301d3 (diff)
- Chalice-to-C# compiler now supports channels
Diffstat (limited to 'Chalice/src/Chalice.cs')
-rw-r--r--Chalice/src/Chalice.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/Chalice/src/Chalice.cs b/Chalice/src/Chalice.cs
index f4a804e7..4865db69 100644
--- a/Chalice/src/Chalice.cs
+++ b/Chalice/src/Chalice.cs
@@ -5,6 +5,7 @@
//-----------------------------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
+using System.Threading;
namespace Chalice
{
@@ -64,6 +65,28 @@ namespace Chalice
return l;
}
}
+
+ public class ChannelBuffer<E> {
+ private LinkedList<E> contents = new LinkedList<E>();
+
+ public void Add(E e) {
+ lock(this) {
+ contents.AddFirst(e);
+ Monitor.Pulse(this);
+ }
+ }
+
+ public E Remove() {
+ lock(this) {
+ while(contents.Count == 0){
+ Monitor.Wait(this);
+ }
+ E e = contents.Last.Value;
+ contents.RemoveLast();
+ return e;
+ }
+ }
+ }
public class ChalicePrint {
public void Int(int x) {