comparison lib/js/urweb.js @ 1794:4671afac15af

Change 'spawn' implementation to allow blocking within <active code>
author Adam Chlipala <adam@chlipala.net>
date Wed, 25 Jul 2012 08:20:15 -0400
parents 446e73902b09
children 10a2cb93d175
comparison
equal deleted inserted replaced
1793:446e73902b09 1794:4671afac15af
1295 window.location = s; 1295 window.location = s;
1296 } 1296 }
1297 1297
1298 function rc(prefix, uri, parse, k, needsSig) { 1298 function rc(prefix, uri, parse, k, needsSig) {
1299 if (!maySuspend) 1299 if (!maySuspend)
1300 er("May not 'rpc' in 'code' for <active>"); 1300 er("May not 'rpc' in main thread of 'code' for <active>");
1301 1301
1302 uri = cat(prefix, uri); 1302 uri = cat(prefix, uri);
1303 uri = flattenLocal(uri); 1303 uri = flattenLocal(uri);
1304 var xhr = getXHR(); 1304 var xhr = getXHR();
1305 1305
1476 connect(); 1476 connect();
1477 } 1477 }
1478 1478
1479 function rv(chn, parse, k) { 1479 function rv(chn, parse, k) {
1480 if (!maySuspend) 1480 if (!maySuspend)
1481 er("May not 'recv' in 'code' for <active>"); 1481 er("May not 'recv' in main thread of 'code' for <active>");
1482 1482
1483 if (chn == null) 1483 if (chn == null)
1484 return; 1484 return;
1485 1485
1486 if (chn < 0) 1486 if (chn < 0)
1506 } 1506 }
1507 } 1507 }
1508 1508
1509 function sl(ms, k) { 1509 function sl(ms, k) {
1510 if (!maySuspend) 1510 if (!maySuspend)
1511 er("May not 'sleep' in 'code' for <active>"); 1511 er("May not 'sleep' in main thread of 'code' for <active>");
1512 1512
1513 window.setTimeout(function() { k(null); }, ms); 1513 window.setTimeout(function() { k(null); }, ms);
1514 } 1514 }
1515 1515
1516 function sp(e) { 1516 function sp(e) {
1517 execF(e, null); 1517 window.setTimeout(function() { execF(e); }, 0);
1518 } 1518 }
1519 1519
1520 1520
1521 // The Ur interpreter 1521 // The Ur interpreter
1522 1522