Creates a new coordinated button the worker configuration described by `scope`.
(
scope: Scope<'scope, T>,
addr: Rc<[usize]>,
)
| 724 | |
| 725 | /// Creates a new coordinated button the worker configuration described by `scope`. |
| 726 | pub fn button<'scope, T: Timestamp>( |
| 727 | scope: Scope<'scope, T>, |
| 728 | addr: Rc<[usize]>, |
| 729 | ) -> (ButtonHandle, Button) { |
| 730 | let index = scope.worker().new_identifier(); |
| 731 | let (pushers, puller) = scope.worker().allocate(index, addr); |
| 732 | |
| 733 | let local_pressed = Rc::new(Cell::new(false)); |
| 734 | |
| 735 | let handle = ButtonHandle { |
| 736 | buttons_remaining: scope.peers(), |
| 737 | local_pressed: Rc::clone(&local_pressed), |
| 738 | puller, |
| 739 | }; |
| 740 | |
| 741 | let token = Button { |
| 742 | pushers, |
| 743 | local_pressed, |
| 744 | }; |
| 745 | |
| 746 | (handle, token) |
| 747 | } |
| 748 | |
| 749 | /// A button that can be used to coordinate an action after all workers have pressed it. |
| 750 | pub struct ButtonHandle { |
no test coverage detected