move the owner tag inside
parent
468c3a07d4
commit
c854e9d189
|
@ -560,7 +560,6 @@ struct LIBCUBESCRIPT_EXPORT state {
|
||||||
void swap(state &s) {
|
void swap(state &s) {
|
||||||
std::swap(p_tstate, s.p_tstate);
|
std::swap(p_tstate, s.p_tstate);
|
||||||
std::swap(identflags, s.identflags);
|
std::swap(identflags, s.identflags);
|
||||||
std::swap(p_owner, s.p_owner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state new_thread();
|
state new_thread();
|
||||||
|
@ -733,8 +732,6 @@ private:
|
||||||
ident *add_ident(ident *id, ident_impl *impl);
|
ident *add_ident(ident *id, ident_impl *impl);
|
||||||
|
|
||||||
void *alloc(void *ptr, size_t olds, size_t news);
|
void *alloc(void *ptr, size_t olds, size_t news);
|
||||||
|
|
||||||
bool p_owner = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stack_state_node {
|
struct stack_state_node {
|
||||||
|
|
|
@ -71,7 +71,7 @@ state::state(alloc_func func, void *data) {
|
||||||
|
|
||||||
p_tstate->pstate = this;
|
p_tstate->pstate = this;
|
||||||
p_tstate->istate = statep;
|
p_tstate->istate = statep;
|
||||||
p_owner = true;
|
p_tstate->owner = true;
|
||||||
|
|
||||||
for (int i = 0; i < MAX_ARGUMENTS; ++i) {
|
for (int i = 0; i < MAX_ARGUMENTS; ++i) {
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
@ -188,7 +188,7 @@ LIBCUBESCRIPT_EXPORT state::~state() {
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBCUBESCRIPT_EXPORT void state::destroy() {
|
LIBCUBESCRIPT_EXPORT void state::destroy() {
|
||||||
if (!p_tstate || !p_owner) {
|
if (!p_tstate || !p_tstate->owner) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto *sp = p_tstate->istate;
|
auto *sp = p_tstate->istate;
|
||||||
|
@ -205,9 +205,7 @@ LIBCUBESCRIPT_EXPORT void state::destroy() {
|
||||||
sp->destroy(sp);
|
sp->destroy(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
state::state(internal_state *s):
|
state::state(internal_state *s) {
|
||||||
p_owner{false}
|
|
||||||
{
|
|
||||||
p_tstate = s->create<thread_state>(s);
|
p_tstate = s->create<thread_state>(s);
|
||||||
p_tstate->istate = s;
|
p_tstate->istate = s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ struct thread_state {
|
||||||
hook_func call_hook{};
|
hook_func call_hook{};
|
||||||
/* loop nesting level */
|
/* loop nesting level */
|
||||||
int loop_level = 0;
|
int loop_level = 0;
|
||||||
|
/* whether we own the internal state (i.e. not a side thread */
|
||||||
|
bool owner = false;
|
||||||
|
|
||||||
thread_state(internal_state *cs);
|
thread_state(internal_state *cs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue