[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Pooling of strings is good
- From: Sean Conner <sean@...>
- Date: Wed, 27 Aug 2014 17:58:36 -0400
It was thus said that the Great Coroutines once stated:
> On Sat, Aug 23, 2014 at 12:47 AM, Coroutines <coroutines@gmail.com> wrote:
>
> > My bad, I thought I read static :\ Stack overflows are fun... :p I
> > was just thinking offhandedly that you could create a mmap, expose it
> > to Lua as a file to read and write from -- and pass it to the
> > networking lib as the buffer to recv into. Hmm. And it could be
> > shared depending on the threading setup -- but that's an afterthought.
>
> Hmm. This is another tangent -- mostly talking to Sean here.
I'm stil here.
> I was off-base when I said mmap() -- I haven't used mmap() often and for
> some reason I thought I could take a [page-sized] block of memory and get
> an fd from it. WRONG. I was really thinking of shm_open().
shm_open() doesn't do what you think it does.
int shm_open(const char *name, int oflag, mode_t mode);
That "name" there is the name of a file; if the name doesn't exist, a file
is created with that name (and I'm checking the man pages of three different
systems here).
No, what you want is open_memstream(). It's a POSIX function, so it'll
exist on Linux and Mac. I don't know what you would do under Windows, but I
would double check the documentation for CreateFileMapping() to make sure it
does what you think it does.
> I wouldn't be sharing the userdata memory, just making it "fd-accessible".
> I'm thinking about making a library to expose userdata to Lua as file
> handles. You'd have userdata exist in one spot in Lua's memory and then
> you'd create the file handle which references that userdata with this
> library. This isn't doing what I'm talking about in this thread, but I
> thought it would be cool.
I really have no idea what possible use this could be (good---plenty of
bad things I can see happening), aside from the "because I can" school of
answers.
-spc