lua-users home
lua-l archive

Re: lua_newstate

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Luiz Henrique de Figueiredo once stated:
> > + pthread_mutex_t lock;
> > } global_State;
> 
> Note that you don't need to change this struct to support OS threads.
> Lua states contain an array of size LUA_EXTRASPACE that can be used
> to store additional data. See also lua_getextraspace. The macros
> luai_userstate* can be defined to manage OS threads.
> 
> Search the archives for examples. Note that LUA_EXTRASPACE was spelled 
> LUAI_EXTRASPACE before 5.3.
 I saw LUA_EXTRASPACE, but I decided against it for a few reasons:
	1) A `void *` may not be big enough to store a pthread_mutex_t.
	2) A `void *` *is* big enough to store a pointer to a
	 pthread_mutex_t, but then I would need to add code to allocate a
	 pthread_mutex_t.
	3) I need to recompile Lua *anyway* with a new defintion for
	 lua_lock() and lua_unlock().
	4) Since this is just for benchmarking, I wanted to do the simplest
	 thing that could work.
 -spc 

AltStyle によって変換されたページ (->オリジナル) /