You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I currently want to multi-thread my code generation, but Builder is inherently mutable. The simple solution would be to just wrap it in a mutex, but that would kill the performance.
One solution that I am thinking of is to create a separate builder object for every node that I traverse, then I would return the builder object and merge them together in the correct order.
The only problem that I see are the ids. If I would want to split the builder object into many small builder objects I would need to keep track of the correct IDs.
#[derive(Default)]
pub struct Builder {
module: mr::Module,
next_id: Arc<AtomicUsize>, // <= from u32 to Arc<AtomicUsize>,
function: Option<mr::Function>,
basic_block: Option<mr::BasicBlock>,
}
One solution would be to use an Arc<AtomicUsize>, this could also made generic.
And and append function to merge them together. builder.append(other_builder);
What are your thoughts?
The text was updated successfully, but these errors were encountered:
I currently want to multi-thread my code generation, but Builder is inherently mutable. The simple solution would be to just wrap it in a mutex, but that would kill the performance.
One solution that I am thinking of is to create a separate builder object for every node that I traverse, then I would return the builder object and merge them together in the correct order.
The only problem that I see are the ids. If I would want to split the builder object into many small builder objects I would need to keep track of the correct IDs.
One solution would be to use an
Arc<AtomicUsize>
, this could also made generic.And and
append
function to merge them together.builder.append(other_builder);
What are your thoughts?
The text was updated successfully, but these errors were encountered: