Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement async send. #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ImagicTheCat
Copy link
Contributor

@ImagicTheCat ImagicTheCat commented Nov 18, 2021

I couldn't get the tests to work (wrote one anyway), but I did manual testing and integration into an existing project without issues.
(from #25)

With flexible multi-threading support.
Copy link
Owner

@brimworks brimworks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what the "right" answer is to this problem, but my concern with the current solution is in regards to object lifetimes and the fact that we can now crash the process... and if someone uses this API thinking it is safe, they will request support.

Thank you for the contribution, but at this time, I'd only support the addition of the ev.ASYNC constant and async:send(loop) additions, until we can think about a better way to handle the sending/receiving of the async/loop handlers in a way that is safe.

void *udata = lua_touserdata(L, lua_upvalueindex(1));
struct async_serialized* data = (struct async_serialized*)udata;

ev_async_send(data->loop, data->async);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we ensure the lifetime of the data->async is still valid when this is called?

luaL_error(L, "invalid data size");

void* data = lua_newuserdata(L, sizeof(struct async_serialized));
memcpy(data, str, sizeof(struct async_serialized));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we ensure that the memory pointed to by the fields of the async_serialized structure are still valid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants