Mir

Merge lp:~raof/mir/scratch-threadsafe-list-itch into lp:mir

Proposed by Chris Halse Rogers on 2015-10-21
Status: Superseded
Proposed branch: lp:~raof/mir/scratch-threadsafe-list-itch
Merge into: lp:mir
Diff against target: 0 lines
To merge this branch: bzr merge lp:~raof/mir/scratch-threadsafe-list-itch
Reviewer Review Type Date Requested Status
Andreas Pokorny (community) 2015-10-21 Needs Information on 2015-10-21
Review via email: mp+275139@code.launchpad.net

This proposal has been superseded by a proposal from 2015-10-21.

Commit Message

Simplify ThreadSafeList (by relaxing an invariant).

It's almost never a good idea to modify the list as you're iterating over it.
Where it *is* sensible, being able to remove yourself from subsequent runs is good enough."

Description of the Change

Scratch my threadsafe-list itch.Simplify ThreadSafeList (by relaxing an invariant).

I find this substantially easier to reason about, and it's almost certainly faster for the common case of iterate-often, mutate seldom.

To post a comment you must log in.
Chris Halse Rogers (raof) wrote :

Bah! Unrelated changes!

3042. By Daniel van Vugt on 2015-10-21

Welcome to series 0.18.

Approved by PS Jenkins bot.

Andreas Pokorny (andreas-pokorny) wrote :

I think you could avoid a copy in the mutating functions by testing use_count == 1 after acquiring the lock.

lgtm.

review: Needs Information
3043. By Brandon Schaefer on 2015-10-21

Add a comment explaining the need for this temp variable.

Approved by Daniel van Vugt, PS Jenkins bot, Kevin DuBois.

3044. By Chris Halse Rogers on 2015-10-21

Simplify ThreadSafeList (by relaxing an invariant).

It's almost never a good idea to modify the list as you're iterating over it.
Where it *is* sensible, being able to remove yourself from subsequent runs
is good enough.

3045. By Chris Halse Rogers on 2015-10-21

Optimise the no-contention case for ThreadSafeList mutation

Unmerged revisions

3045. By Chris Halse Rogers on 2015-10-21

Optimise the no-contention case for ThreadSafeList mutation

3044. By Chris Halse Rogers on 2015-10-21

Simplify ThreadSafeList (by relaxing an invariant).

It's almost never a good idea to modify the list as you're iterating over it.
Where it *is* sensible, being able to remove yourself from subsequent runs
is good enough.

Preview Diff

Empty

Subscribers

People subscribed via source and target branches