summaryrefslogtreecommitdiff
path: root/src/lanes.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lanes.c')
-rw-r--r--src/lanes.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/lanes.c b/src/lanes.c
index 8f5768f..9f455b2 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -51,7 +51,7 @@
51 * ... 51 * ...
52 */ 52 */
53 53
54char const* VERSION = "3.1.6"; 54char const* VERSION = "3.2.0";
55 55
56/* 56/*
57=============================================================================== 57===============================================================================
@@ -309,7 +309,7 @@ LUAG_FUNC( linda_send)
309 for( ;;) 309 for( ;;)
310 { 310 {
311 STACK_MID(KL, 0) 311 STACK_MID(KL, 0)
312 pushed = keeper_call( KL, "send", L, linda, key_i); 312 pushed = keeper_call( KL, KEEPER_API( send), L, linda, key_i);
313 if( pushed < 0) 313 if( pushed < 0)
314 { 314 {
315 break; 315 break;
@@ -410,7 +410,7 @@ LUAG_FUNC( linda_receive)
410 struct s_Linda *linda = lua_toLinda( L, 1); 410 struct s_Linda *linda = lua_toLinda( L, 1);
411 int pushed, expected_pushed_min, expected_pushed_max; 411 int pushed, expected_pushed_min, expected_pushed_max;
412 bool_t cancel = FALSE; 412 bool_t cancel = FALSE;
413 char *keeper_receive; 413 keeper_api_t keeper_receive;
414 414
415 time_d timeout = -1.0; 415 time_d timeout = -1.0;
416 uint_t key_i = 2; 416 uint_t key_i = 2;
@@ -440,7 +440,7 @@ LUAG_FUNC( linda_receive)
440 // make sure the keys are of a valid type 440 // make sure the keys are of a valid type
441 check_key_types( L, key_i, key_i); 441 check_key_types( L, key_i, key_i);
442 // receive multiple values from a single slot 442 // receive multiple values from a single slot
443 keeper_receive = "receive_batched"; 443 keeper_receive = KEEPER_API( receive_batched);
444 // we expect a user-defined amount of return value 444 // we expect a user-defined amount of return value
445 expected_pushed_min = (int)luaL_checkinteger( L, key_i + 1); 445 expected_pushed_min = (int)luaL_checkinteger( L, key_i + 1);
446 expected_pushed_max = (int)luaL_optinteger( L, key_i + 2, expected_pushed_min); 446 expected_pushed_max = (int)luaL_optinteger( L, key_i + 2, expected_pushed_min);
@@ -454,7 +454,7 @@ LUAG_FUNC( linda_receive)
454 // make sure the keys are of a valid type 454 // make sure the keys are of a valid type
455 check_key_types( L, key_i, lua_gettop( L)); 455 check_key_types( L, key_i, lua_gettop( L));
456 // receive a single value, checking multiple slots 456 // receive a single value, checking multiple slots
457 keeper_receive = "receive"; 457 keeper_receive = KEEPER_API( receive);
458 // we expect a single (value, key) pair of returned values 458 // we expect a single (value, key) pair of returned values
459 expected_pushed_min = expected_pushed_max = 2; 459 expected_pushed_min = expected_pushed_max = 2;
460 } 460 }
@@ -558,6 +558,7 @@ LUAG_FUNC( linda_set)
558 struct s_Linda *linda = lua_toLinda( L, 1); 558 struct s_Linda *linda = lua_toLinda( L, 1);
559 bool_t has_value = !lua_isnil( L, 3); 559 bool_t has_value = !lua_isnil( L, 3);
560 luaL_argcheck( L, linda, 1, "expected a linda object!"); 560 luaL_argcheck( L, linda, 1, "expected a linda object!");
561 luaL_argcheck( L, lua_gettop( L) <= 3, 4, "too many arguments");
561 562
562 // make sure the key is of a valid type 563 // make sure the key is of a valid type
563 check_key_types( L, 2, 2); 564 check_key_types( L, 2, 2);
@@ -566,7 +567,7 @@ LUAG_FUNC( linda_set)
566 int pushed; 567 int pushed;
567 struct s_Keeper *K = keeper_acquire( linda); 568 struct s_Keeper *K = keeper_acquire( linda);
568 // no nil->sentinel toggling, we really clear the linda contents for the given key with a set() 569 // no nil->sentinel toggling, we really clear the linda contents for the given key with a set()
569 pushed = keeper_call( K->L, "set", L, linda, 2); 570 pushed = keeper_call( K->L, KEEPER_API( set), L, linda, 2);
570 if( pushed >= 0) // no error? 571 if( pushed >= 0) // no error?
571 { 572 {
572 ASSERT_L( pushed == 0); 573 ASSERT_L( pushed == 0);
@@ -606,7 +607,7 @@ LUAG_FUNC( linda_count)
606 607
607 { 608 {
608 struct s_Keeper *K = keeper_acquire( linda); 609 struct s_Keeper *K = keeper_acquire( linda);
609 pushed = keeper_call( K->L, "count", L, linda, 2); 610 pushed = keeper_call( K->L, KEEPER_API( count), L, linda, 2);
610 keeper_release( K); 611 keeper_release( K);
611 if( pushed < 0) 612 if( pushed < 0)
612 { 613 {
@@ -634,7 +635,7 @@ LUAG_FUNC( linda_get)
634 635
635 { 636 {
636 struct s_Keeper *K = keeper_acquire( linda); 637 struct s_Keeper *K = keeper_acquire( linda);
637 pushed = keeper_call( K->L, "get", L, linda, 2); 638 pushed = keeper_call( K->L, KEEPER_API( get), L, linda, 2);
638 ASSERT_L( pushed==0 || pushed==1 ); 639 ASSERT_L( pushed==0 || pushed==1 );
639 if( pushed > 0) 640 if( pushed > 0)
640 { 641 {
@@ -659,15 +660,19 @@ LUAG_FUNC( linda_get)
659*/ 660*/
660LUAG_FUNC( linda_limit) 661LUAG_FUNC( linda_limit)
661{ 662{
662 struct s_Linda *linda= lua_toLinda( L, 1 ); 663 struct s_Linda* linda= lua_toLinda( L, 1 );
663 664
664 luaL_argcheck( L, linda, 1, "expected a linda object!"); 665 luaL_argcheck( L, linda, 1, "expected a linda object!");
666 // make sure we got a key and a limit
667 luaL_argcheck( L, lua_gettop( L) == 3, 2, "wrong number of arguments");
668 // make sure we got a numeric limit
669 luaL_checknumber( L, 3);
665 // make sure the key is of a valid type 670 // make sure the key is of a valid type
666 check_key_types( L, 2, 2); 671 check_key_types( L, 2, 2);
667 672
668 { 673 {
669 struct s_Keeper *K = keeper_acquire( linda); 674 struct s_Keeper* K = keeper_acquire( linda);
670 int pushed = keeper_call( K->L, "limit", L, linda, 2); 675 int pushed = keeper_call( K->L, KEEPER_API( limit), L, linda, 2);
671 ASSERT_L( pushed <= 0); // either error or no return values 676 ASSERT_L( pushed <= 0); // either error or no return values
672 keeper_release( K); 677 keeper_release( K);
673 // must trigger error after keeper state has been released 678 // must trigger error after keeper state has been released
@@ -825,8 +830,8 @@ static void linda_id( lua_State *L, char const * const which)
825 K= keeper_acquire(s); 830 K= keeper_acquire(s);
826 if( K && K->L) // can be NULL if this happens during main state shutdown (lanes is GC'ed -> no keepers -> no need to cleanup) 831 if( K && K->L) // can be NULL if this happens during main state shutdown (lanes is GC'ed -> no keepers -> no need to cleanup)
827 { 832 {
828 keeper_call( K->L, "clear", L, s, 0 ); 833 keeper_call( K->L, KEEPER_API( clear), L, s, 0 );
829 keeper_release(K); 834 keeper_release( K);
830 } 835 }
831 836
832 /* There aren't any lanes waiting on these lindas, since all proxies 837 /* There aren't any lanes waiting on these lindas, since all proxies