From 934f2a9a90c5cad3cdc8a66b50c17827a3ddbcee Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 20 Jan 2018 13:46:11 +0200 Subject: Get rid of action rule override semantics Instead we now have two more or less separate match states for outer and inner parts of an action. --- build2/variable.cxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'build2/variable.cxx') diff --git a/build2/variable.cxx b/build2/variable.cxx index d1f95c5..eb74aad 100644 --- a/build2/variable.cxx +++ b/build2/variable.cxx @@ -302,7 +302,7 @@ namespace build2 } void - typify (value& v, const value_type& t, const variable* var) + typify (value& v, const value_type& t, const variable* var, memory_order mo) { if (v.type == nullptr) { @@ -312,11 +312,16 @@ namespace build2 // names ns (move (v).as ()); v = nullptr; - v.type = &t; - v.assign (move (ns), var); + + // Use value_type::assign directly to delay v.type change. + // + t.assign (v, move (ns), var); + v.null = false; } else v.type = &t; + + v.type.store (&t, mo); } else if (v.type != &t) { @@ -342,8 +347,10 @@ namespace build2 variable_cache_mutex_shard[ hash () (&v) % variable_cache_mutex_shard_size]); + // Note: v.type is rechecked by typify() under lock. + // ulock l (m); - typify (v, t, var); // v.type is rechecked by typify(), stored under lock. + typify (v, t, var, memory_order_release); } void -- cgit v1.1