move the owner tag inside

master
Daniel Kolesa 2021-03-25 01:55:47 +01:00
parent 468c3a07d4
commit c854e9d189
3 changed files with 5 additions and 8 deletions

View File

@ -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 {

View File

@ -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;
} }

View File

@ -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);