|
Boost : |
Subject: Re: [boost] [next gen future-promise] What to call themonadicreturntype?
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2015-05-26 05:29:57
On 26 May 2015 at 3:50, Gottlob Frege wrote:
> Alternatively, with a lock in each and pointers pointing to each other, you
> avoid deadlock by first setting (via CAS) your own state to be "I'm moving"
> then (if successful) setting your partner's flag to "see ya later", then
> (if successful) moving.
>
> No one moves without telling the other first. You can get a live lock, but
> not a dead lock. The live Lock can be dealt with (particularly easily since
> the relationship (promise vs future) is asymmetrical - just say future
> always goes first, for example).
I found via empirical testing that the number of occasions when two
threads both access promise and future concurrently is extremely
rare. The stupidly simple method of locking both for every access I
didn't find was a problem. And it's easy to test, and verify with the
thread sanitiser.
Niall
-- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk