-
Notifications
You must be signed in to change notification settings - Fork 45
add NOSHARE flag #336
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
base: master
Are you sure you want to change the base?
add NOSHARE flag #336
Conversation
lunatik.h
Outdated
| #define LUNATIK_VERSION "Lunatik 3.7" | ||
|
|
||
| #define LUNATIK_CLASS_SLEEPABLE 0x01 | ||
| #define LUNATIK_CLASS_NOSHARE 0x02 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do you handle allocations? we could have "single" mode objects that might or might not sleep on allocation, besides the fact they aren't shared. Perhaps, a better idea is to have two bools instead of flags, sleep and shared. What do you think?
3fff47b to
46a783a
Compare
| #define lunatik_object_issleepable(obj) ((obj)->sleep) | ||
| #define lunatik_class_issleepable(cls) ((cls)->sleep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #define lunatik_object_issleepable(obj) ((obj)->sleep) | |
| #define lunatik_class_issleepable(cls) ((cls)->sleep) | |
| #define lunatik_issleepable(o) ((o)->sleep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, I wouldn't change this on the same PR.. it seems only cosmetic and not require to the main change your are adding.. let's keep the patches as self-contained as possible..
| const luaL_Reg *methods; | ||
| void (*release)(void *); | ||
| bool sleep; | ||
| bool shared; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should invert this flag.. so we don't need to change all modules and just the places we really need (such as pointer)..
| bool shared; | |
| bool single; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually.. I wouldn't add this to class now, we don't need classes that are exclusively "single", right? I would just have it on object
| if (!object->shared) | ||
| luaL_error(L, "%s objects cannot be shared across runtimes", object->class->name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not enough, right? we probably need to add single flag to the API for creating new objects..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, avoiding creating mutex/spinlock and refcount unnecessarily..
| union { | ||
| struct mutex mutex; | ||
| spinlock_t spin; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should have a substruct allocated dynamically for kref and lock.. but let's worry about this after having the first version settled..
| #define LUADATA_OPT_NONE 0x00 | ||
| #define LUADATA_OPT_READONLY 0x01 | ||
| #define LUADATA_OPT_FREE 0x02 | ||
| #define LUADATA_OPT_SINGLE 0x04 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can just use the obj flag, right?
| static int luadata_lnew(lua_State *L) | ||
| { | ||
| size_t size = (size_t)luaL_checkinteger(L, 1); | ||
| bool single = lua_toboolean(L, 2); /* false -> sharable */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| bool single = lua_toboolean(L, 2); /* false -> sharable */ | |
| bool single = lua_toboolean(L, 2); |
| #define lunatik_class_issleepable(cls) ((cls)->sleep) | ||
|
|
||
| #define lunatik_locker(o, mutex_op, spin_op) \ | ||
| do { \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should check if it's single, right? it should lock in that case.. also, refcount shouldn't be applied if single
No description provided.