github.com/haraldrudell/parl@v0.4.176/if-done.go (about) 1 /* 2 © 2024–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 package parl 7 8 // Done declares an object with a Done method 9 // - The Done interface is similar to a done callback function value 10 // - — passing a method as function value causes allocation 11 // - — such function values create difficult-to-follow stack traces 12 // - The Done interface implemented by eg. [sync.WaitGroup.Done] 13 // - callbacks are used when: 14 // - — invoked repeatedly 15 // - — invoked by a subthread or asynchronous method 16 // - a thread-safe callback may save a listening thread and a lock 17 // - alternatives to callback are: 18 // - — blocking return or 19 // - — lock-featuring synchronization mechanics like chan costing a thread 20 type Done interface { 21 // Done signals that some task has completed. 22 Done() 23 }