diff options
| author | Benoit Germain <bnt.germain@gmail.com> | 2013-11-07 10:24:02 +0100 |
|---|---|---|
| committer | Benoit Germain <bnt.germain@gmail.com> | 2013-11-07 10:24:02 +0100 |
| commit | 15ced800ad7b9e57369d17cdd7676883d938062f (patch) | |
| tree | 08c8f862fa97e34c87f906f94fa89c89db9798ba /src | |
| parent | 0583f7008a38fdce379f383fe6933ec9f67fd59f (diff) | |
| download | lanes-15ced800ad7b9e57369d17cdd7676883d938062f.tar.gz lanes-15ced800ad7b9e57369d17cdd7676883d938062f.tar.bz2 lanes-15ced800ad7b9e57369d17cdd7676883d938062f.zip | |
Make set_finalizer(), set_debug_threadname(), cancel_test() and set_error_reporting() transferable from lane to lane
Diffstat (limited to 'src')
| -rw-r--r-- | src/lanes.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lanes.c b/src/lanes.c index b383b40..4005955 100644 --- a/src/lanes.c +++ b/src/lanes.c | |||
| @@ -1764,7 +1764,7 @@ static THREAD_RETURN_T THREAD_CALLCONV lane_main( void *vs) | |||
| 1764 | struct s_lane *s= (struct s_lane *)vs; | 1764 | struct s_lane *s= (struct s_lane *)vs; |
| 1765 | int rc, rc2; | 1765 | int rc, rc2; |
| 1766 | lua_State*L= s->L; | 1766 | lua_State*L= s->L; |
| 1767 | 1767 | STACK_CHECK( L); | |
| 1768 | #if HAVE_LANE_TRACKING | 1768 | #if HAVE_LANE_TRACKING |
| 1769 | if( tracking_first) | 1769 | if( tracking_first) |
| 1770 | { | 1770 | { |
| @@ -1772,28 +1772,32 @@ static THREAD_RETURN_T THREAD_CALLCONV lane_main( void *vs) | |||
| 1772 | } | 1772 | } |
| 1773 | #endif // HAVE_LANE_TRACKING | 1773 | #endif // HAVE_LANE_TRACKING |
| 1774 | 1774 | ||
| 1775 | s->status= RUNNING; // PENDING -> RUNNING | 1775 | s->status= RUNNING; // PENDING -> RUNNING |
| 1776 | 1776 | ||
| 1777 | // Tie "set_finalizer()" to the state | 1777 | // Tie "set_finalizer()" to the state |
| 1778 | // | 1778 | // |
| 1779 | lua_pushcfunction( L, LG_set_finalizer ); | 1779 | lua_pushcfunction( L, LG_set_finalizer ); |
| 1780 | lua_setglobal( L, "set_finalizer" ); | 1780 | populate_func_lookup_table( L, -1, "set_finalizer"); |
| 1781 | lua_setglobal( L, "set_finalizer"); | ||
| 1781 | 1782 | ||
| 1782 | // Tie "set_debug_threadname()" to the state | 1783 | // Tie "set_debug_threadname()" to the state |
| 1783 | // | 1784 | // |
| 1784 | lua_pushlightuserdata( L, s); | 1785 | lua_pushlightuserdata( L, s); |
| 1785 | lua_pushcclosure( L, LG_set_debug_threadname, 1); | 1786 | lua_pushcclosure( L, LG_set_debug_threadname, 1); |
| 1787 | populate_func_lookup_table( L, -1, "set_debug_threadname"); | ||
| 1786 | lua_setglobal( L, "set_debug_threadname" ); | 1788 | lua_setglobal( L, "set_debug_threadname" ); |
| 1787 | 1789 | ||
| 1788 | // Tie "cancel_test()" to the state | 1790 | // Tie "cancel_test()" to the state |
| 1789 | // | 1791 | // |
| 1790 | lua_pushcfunction( L, LG_cancel_test); | 1792 | lua_pushcfunction( L, LG_cancel_test); |
| 1793 | populate_func_lookup_table( L, -1, "cancel_test"); | ||
| 1791 | lua_setglobal( L, "cancel_test"); | 1794 | lua_setglobal( L, "cancel_test"); |
| 1792 | 1795 | ||
| 1793 | #if ERROR_FULL_STACK | 1796 | #if ERROR_FULL_STACK |
| 1794 | // Tie "set_error_reporting()" to the state | 1797 | // Tie "set_error_reporting()" to the state |
| 1795 | // | 1798 | // |
| 1796 | lua_pushcfunction( L, LG_set_error_reporting); | 1799 | lua_pushcfunction( L, LG_set_error_reporting); |
| 1800 | populate_func_lookup_table( L, -1, "set_error_reporting"); | ||
| 1797 | lua_setglobal( L, "set_error_reporting"); | 1801 | lua_setglobal( L, "set_error_reporting"); |
| 1798 | 1802 | ||
| 1799 | STACK_GROW( L, 1 ); | 1803 | STACK_GROW( L, 1 ); |
| @@ -1841,6 +1845,7 @@ static THREAD_RETURN_T THREAD_CALLCONV lane_main( void *vs) | |||
| 1841 | // LUA_ERRMEM(4): memory allocation error | 1845 | // LUA_ERRMEM(4): memory allocation error |
| 1842 | #endif // ERROR_FULL_STACK | 1846 | #endif // ERROR_FULL_STACK |
| 1843 | 1847 | ||
| 1848 | STACK_END( L, 0); | ||
| 1844 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "Lane %p body: %s (%s)\n" INDENT_END, L, get_errcode_name( rc), (lua_touserdata(L,1)==CANCEL_ERROR) ? "cancelled" : lua_typename( L, lua_type( L, 1)))); | 1849 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "Lane %p body: %s (%s)\n" INDENT_END, L, get_errcode_name( rc), (lua_touserdata(L,1)==CANCEL_ERROR) ? "cancelled" : lua_typename( L, lua_type( L, 1)))); |
| 1845 | //STACK_DUMP(L); | 1850 | //STACK_DUMP(L); |
| 1846 | // Call finalizers, if the script has set them up. | 1851 | // Call finalizers, if the script has set them up. |
