aboutsummaryrefslogtreecommitdiff
path: root/src/keeper.c
diff options
context:
space:
mode:
authorBenoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m>2013-11-29 20:33:46 +0100
committerBenoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m>2013-11-29 20:33:46 +0100
commitff74281fc94cda26b2d0a7fc2424f24fe2488718 (patch)
tree6e8aa44d300ccd5da451d02c08cee98090328b60 /src/keeper.c
parentb4cd90c9e9a7898775d173df2267d1860dcbc699 (diff)
downloadlanes-ff74281fc94cda26b2d0a7fc2424f24fe2488718.tar.gz
lanes-ff74281fc94cda26b2d0a7fc2424f24fe2488718.tar.bz2
lanes-ff74281fc94cda26b2d0a7fc2424f24fe2488718.zip
supposedly improved pthread support
* bumped version to 3.7.3 * set pthread thread cancel type to PTHREAD_CANCEL_ASYNCHRONOUS * lane_h:cancel() accepts a 3rd timeout argument used when waiting for actual thread termination (hitting the timeout raises an error) * added PROPAGATE_ALLOCF macro to select state creation mode (lua_newstate or luaL_newstate)
Diffstat (limited to 'src/keeper.c')
-rw-r--r--src/keeper.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/keeper.c b/src/keeper.c
index 8da3c08..99f510b 100644
--- a/src/keeper.c
+++ b/src/keeper.c
@@ -567,8 +567,7 @@ void close_keepers( void)
567char const* init_keepers( lua_State* L) 567char const* init_keepers( lua_State* L)
568{ 568{
569 int i; 569 int i;
570 void* allocUD; 570 PROPAGATE_ALLOCF_PREP( L);
571 lua_Alloc allocF = lua_getallocf( L, &allocUD);
572 571
573 STACK_CHECK( L); 572 STACK_CHECK( L);
574 lua_getfield( L, 1, "nb_keepers"); 573 lua_getfield( L, 1, "nb_keepers");
@@ -580,10 +579,10 @@ char const* init_keepers( lua_State* L)
580 GKeepers = malloc( GNbKeepers * sizeof( struct s_Keeper)); 579 GKeepers = malloc( GNbKeepers * sizeof( struct s_Keeper));
581 for( i = 0; i < GNbKeepers; ++ i) 580 for( i = 0; i < GNbKeepers; ++ i)
582 { 581 {
583 lua_State* K = lua_newstate( allocF, allocUD); 582 lua_State* K = PROPAGATE_ALLOCF_ALLOC();
584 if( K == NULL) 583 if( K == NULL)
585 { 584 {
586 (void) luaL_error( L, "'lua_newstate()' failed while creating keeper state; out of memory"); 585 (void) luaL_error( L, "init_keepers() failed while creating keeper state; out of memory");
587 } 586 }
588 STACK_CHECK( K); 587 STACK_CHECK( K);
589 588
@@ -627,7 +626,7 @@ struct s_Keeper* keeper_acquire( void const* ptr)
627 * have to cast to unsigned long to avoid compilation warnings about loss of data when converting pointer-to-integer 626 * have to cast to unsigned long to avoid compilation warnings about loss of data when converting pointer-to-integer
628 */ 627 */
629 unsigned int i = (unsigned int)(((unsigned long)(ptr) >> 3) % GNbKeepers); 628 unsigned int i = (unsigned int)(((unsigned long)(ptr) >> 3) % GNbKeepers);
630 struct s_Keeper* K = &GKeepers[i]; 629 struct s_Keeper *K= &GKeepers[i];
631 630
632 MUTEX_LOCK( &K->lock_); 631 MUTEX_LOCK( &K->lock_);
633 //++ K->count; 632 //++ K->count;