File tree 2 files changed +11
-0
lines changed 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,16 @@ impl<'lua> Context<'lua> {
234
234
}
235
235
}
236
236
237
+ /// Returns a handle to the active `Thread` for this `Context`. For calls to `Lua::context`
238
+ /// this will be the main Lua thread, for `Context` parameters given to a callback, this will be
239
+ /// whatever Lua thread called the callback.
240
+ pub fn current_thread ( self ) -> Thread < ' lua > {
241
+ unsafe {
242
+ ffi:: lua_pushthread ( self . state ) ;
243
+ Thread ( self . pop_ref ( ) )
244
+ }
245
+ }
246
+
237
247
/// Calls the given function with a `Scope` parameter, giving the function the ability to create
238
248
/// userdata and callbacks from rust types that are !Send or non-'static.
239
249
///
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ extern "C" {
118
118
pub fn lua_pushstring ( state : * mut lua_State , s : * const c_char ) -> * const c_char ;
119
119
pub fn lua_pushlightuserdata ( state : * mut lua_State , data : * mut c_void ) ;
120
120
pub fn lua_pushcclosure ( state : * mut lua_State , function : lua_CFunction , n : c_int ) ;
121
+ pub fn lua_pushthread ( state : * mut lua_State ) -> c_int ;
121
122
122
123
pub fn lua_tointegerx ( state : * mut lua_State , index : c_int , isnum : * mut c_int ) -> lua_Integer ;
123
124
pub fn lua_tolstring ( state : * mut lua_State , index : c_int , len : * mut usize ) -> * const c_char ;
You can’t perform that action at this time.
0 commit comments