event is ultimately called from a function to trigger an event in the engine. We'd like for this to never block, because that makes it much easier to prevent deadlocks in some tricky functions. On the other side, we don't want to necessarily merge events if we want to ensure each sent event gets see
(ctx context.Context, state *state)
| 691 | // again. Instead, we use a buffered channel of size one, and a queue of data |
| 692 | // which stores the event information. |
| 693 | func (obj *Engine) event(ctx context.Context, state *state) error { |
| 694 | //f := state.Func // for reference, how to get the Vertex/Func pointer! |
| 695 | |
| 696 | select { |
| 697 | case obj.ag.In <- state: // buffered to avoid blocking issues |
| 698 | // tell function engine who had an event... deal with it before |
| 699 | // we get to handle subsequent ones... |
| 700 | case <-ctx.Done(): |
| 701 | return ctx.Err() |
| 702 | } |
| 703 | |
| 704 | return nil |
| 705 | } |
| 706 | |
| 707 | // effect runs at the end of the transaction, but before it returns. |
| 708 | // XXX: we don't need delta ops if we can just plug into our implementations of |