summaryrefslogtreecommitdiff
path: root/appl/acme/dat.b
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /appl/acme/dat.b
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'appl/acme/dat.b')
-rw-r--r--appl/acme/dat.b107
1 files changed, 107 insertions, 0 deletions
diff --git a/appl/acme/dat.b b/appl/acme/dat.b
new file mode 100644
index 00000000..924d16e6
--- /dev/null
+++ b/appl/acme/dat.b
@@ -0,0 +1,107 @@
+implement Dat;
+
+include "common.m";
+
+sys : Sys;
+acme : Acme;
+utils : Utils;
+
+# lc, uc : chan of ref Lock;
+
+init(mods : ref Dat->Mods)
+{
+ sys = mods.sys;
+ acme = mods.acme;
+ utils = mods.utils;
+
+ mouse = ref Draw->Pointer;
+ mouse.buttons = mouse.msec = 0;
+ mouse.xy = (0, 0);
+ # lc = chan of ref Lock;
+ # uc = chan of ref Lock;
+ # spawn lockmgr();
+}
+
+# lockmgr()
+# {
+# l : ref Lock;
+#
+# acme->lockpid = sys->pctl(0, nil);
+# for (;;) {
+# alt {
+# l = <- lc =>
+# if (l.cnt++ == 0)
+# l.chann <-= 1;
+# l = <- uc =>
+# if (--l.cnt > 0)
+# l.chann <-= 1;
+# }
+# }
+# }
+
+Lock.init() : ref Lock
+{
+ return ref Lock(0, chan[1] of int);
+ # return ref Lock(0, chan of int);
+}
+
+Lock.lock(l : self ref Lock)
+{
+ l.cnt++;
+ l.chann <-= 0;
+ # lc <-= l;
+ # <- l.chann;
+}
+
+Lock.unlock(l : self ref Lock)
+{
+ <-l.chann;
+ l.cnt--;
+ # uc <-= l;
+}
+
+Lock.locked(l : self ref Lock) : int
+{
+ return l.cnt > 0;
+}
+
+Ref.init() : ref Ref
+{
+ r := ref Ref;
+ r.l = Lock.init();
+ r.cnt = 0;
+ return r;
+}
+
+Ref.inc(r : self ref Ref) : int
+{
+ r.l.lock();
+ i := r.cnt;
+ r.cnt++;
+ r.l.unlock();
+ return i;
+}
+
+Ref.dec(r : self ref Ref) : int
+{
+ r.l.lock();
+ r.cnt--;
+ i := r.cnt;
+ r.l.unlock();
+ return i;
+}
+
+Ref.refx(r : self ref Ref) : int
+{
+ return r.cnt;
+}
+
+Reffont.get(p, q, r : int, b : string) : ref Reffont
+{
+ return acme->get(p, q, r, b);
+}
+
+Reffont.close(r : self ref Reffont)
+{
+ return acme->close(r);
+} \ No newline at end of file