Skip to content

C API for locking array buffers? #1347

@saghul

Description

@saghul

Python has this API for locking a buffer and releasing it afterwards: https://docs.python.org/3/c-api/buffer.html#c.PyBuffer_Release

The way I've used it in the past is to avoid copying data when doing asynchronous writes. You could lock the buffer, get it's data pointer and pass it to libuv for example, since you know it will remain valid and stable. All one needs to do is to keep the Python object alive, which is simple to do by just bumping the refcount.

On to QuickJS :-) I found myself in the same situation. But now we have immutable aray buffers! I'd love to have a way to set / reset the flag from C, so I could keep the chunk I'm sending alive until libuv is done with it.

Say something like: JSArrayBuffer{Get,Set}Immutable(JSContext *ctx, JSObject obj, bool set).

Thoughts?

@bnoordhuis

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions