diff --git a/client.html b/client.html
index 19c8933..92c1be0 100644
--- a/client.html
+++ b/client.html
@@ -233,14 +233,14 @@ function disconnect(addr) {
}*/
// remove locks
// test locks
- for(var i in testLocks) {
+ /*for(var i in testLocks) {
var lock = testLocks[i];
if (!lock)
continue;
if (lock.addr == addr) {
lock.locked = false;
}
- }
+ }*/
// range locks
//removeNodeRangeLocks(addr);
@@ -462,7 +462,7 @@ function loadTest(tname) {
getLock("test", tname);
}
-
+/*
function retrieveLock(struct) {
if (struct.type == "test") {
return testLocks[struct.name];
@@ -472,7 +472,7 @@ function retrieveLock(struct) {
error("retrieveLock for range got null");
return l;
}
-}
+}*/
function getLock(type, name, start, end) {
var locks = getLockType(type);
diff --git a/cortex.js b/cortex.js
index 649b71f..227453a 100644
--- a/cortex.js
+++ b/cortex.js
@@ -256,7 +256,12 @@ function registerFn(fnname, fn, preplace) {
}
}
-
+/* Finds the chain of functions,
+ * calls the nth
+ * stores its return
+ * calls the nth+1 with the return of the nth as well
+ * returns the results of the mth
+ */
function execFn(name, args) {
root = fnreg;
names = name.split(".");
@@ -266,11 +271,12 @@ function execFn(name, args) {
return false; // ERROR, NO FN
}
i=0;
+ ret = true;
while(root[i]) {
- root[i](args);
+ ret = root[i](args, ret);
i++;
}
- return true;
+ return ret;
}
diff --git a/cortexLocks.js b/cortexLocks.js
index d4a3304..41462e3 100644
--- a/cortexLocks.js
+++ b/cortexLocks.js
@@ -6,6 +6,7 @@
* NOTES
*/
+/* locks -> [ name:[type, locks], ] */
var locks = new Array();
var lockTrys = new Array();
var myLocks = new Array();
@@ -17,6 +18,52 @@ function copyobj(arr) {
}
}
+function registerLockFn(ltype, fnName, fn) {
+ registerFn("locks." +ltype+"."+fnName, fn);
+}
+
+function execLockFn(family, fnName, args) {
+ ltype = locks[family].type;
+ args["locks"] = locks[family].locks;
+ return execFn("locks."+ltype+"."+fnName, args);
+}
+
+/**** Lock Functions
+ * retriveLock(details) # get lock data strict (lookup?)
+ * removeLocks(owner)
+ * isLocked(details)
+ * getLock(details) # aquire lock (aquire?)
+ * equals(a, b)
+ * lock
+ * release
+ * make?
+*/
+
+registerLockFn("basic", "lookup",
+function (args) {
+ return args["locks"][args["name"]];
+});
+
+registerLockFn("range", "lookup",
+function (args) {
+ /******* vvvvvvvvvv *********/
+ var l = getRangeLock(struct.name, struct.start, struct.end);
+ if (l == null)
+ error("retrieveLock for range got null");
+ return l;
+});
+
+
+/**** Logical Lock using functions
+ * grant(resp, lock
+ * deny(resp, lock
+ * handleLockReq
+ * handleLockResp
+ * lockGranted
+ * checkLocks
+ * ...
+ */
+
function sendReqs(addr) {
for(ltype in lockTrys) {
for (i in lockTrys[ltype]) {
@@ -95,5 +142,14 @@ function removeNodeLocks(addr) {
addMsgHandler("deadNode",
function (resp) {
+ for(var i in testLocks) {
+ var lock = testLocks[i];
+ if (!lock)
+ continue;
+ if (lock.addr == addr) {
+ lock.locked = false;
+ }
+ }
+
removeNodeLocks(resp['addr']);
-});
\ No newline at end of file
+});