aboutsummaryrefslogtreecommitdiff
path: root/src/threading.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/threading.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/threading.c')
-rw-r--r--src/threading.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/threading.c b/src/threading.c
index 63c39ae..ad5b473 100644
--- a/src/threading.c
+++ b/src/threading.c
@@ -330,6 +330,8 @@ bool_t THREAD_WAIT_IMPL( THREAD_T *ref, double secs)
330 *ref= NULL; 330 *ref= NULL;
331 } 331 }
332 332
333 void THREAD_MAKE_ASYNCH_CANCELLABLE() {} // nothing to do for windows threads, we can cancel them anytime we want
334
333#if !defined __GNUC__ 335#if !defined __GNUC__
334 //see http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx 336 //see http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
335 #define MS_VC_EXCEPTION 0x406D1388 337 #define MS_VC_EXCEPTION 0x406D1388
@@ -896,11 +898,19 @@ bool_t THREAD_WAIT( THREAD_T *ref, double secs , SIGNAL_T *signal_ref, MUTEX_T *
896#endif // THREADWAIT_METHOD == THREADWAIT_CONDVAR 898#endif // THREADWAIT_METHOD == THREADWAIT_CONDVAR
897 return done; 899 return done;
898 } 900 }
899 // 901 //
900 void THREAD_KILL( THREAD_T *ref ) { 902 void THREAD_KILL( THREAD_T *ref ) {
901 pthread_cancel( *ref ); 903 pthread_cancel( *ref );
902 } 904 }
903 905
906 void THREAD_MAKE_ASYNCH_CANCELLABLE()
907 {
908 // that's the default, but just in case...
909 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
910 // we want cancellation to take effect immediately if possible, instead of waiting for a cancellation point (which is the default)
911 pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
912 }
913
904 void THREAD_SETNAME( char const* _name) 914 void THREAD_SETNAME( char const* _name)
905 { 915 {
906 // exact API to set the thread name is platform-dependant 916 // exact API to set the thread name is platform-dependant