Minor error in the sample of DemoDinningPhilosophers

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Minor error in the sample of DemoDinningPhilosophers

Clark
This post has NOT been accepted by the mailing list yet.
Hi, I just want to point out that there may be a bug in the code of this sample:

In the Philosopher object act() method
            react {a ->
                react {b ->
                    if ([a, b].any {Rejected.isCase it}) {
                        println "$name: \tOops, can't get my forks! Giving up."
                        [a, b].find {Accepted.isCase it}?.reply new Finished()
                    } else {
                        eat()
                        reply new Finished() //<-- reply message b only?
                        /* -- should reply to both messages or it will cause the dead lock, use
                        a.reply new Finished()
                        b.reply new Finished()
                        instead?
                        */
                       
                    }
                }
            }