[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua_newstate
- From: Sean Conner <sean@...>
- Date: Thu, 28 Dec 2017 19:08:08 -0500
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
- References:
- Re: lua_newstate, Luiz Henrique de Figueiredo
- Re: lua_newstate, Gregg Reynolds
- Re: lua_newstate, Sean Conner
- Re: lua_newstate, Gregg Reynolds
- Re: lua_newstate, Sean Conner
- Re: lua_newstate, Viacheslav Usov
- Re: lua_newstate, Javier Guerra Giraldez
- Re: lua_newstate, Viacheslav Usov
- Re: lua_newstate, Sean Conner
- Re: lua_newstate, Luiz Henrique de Figueiredo