aboutsummaryrefslogtreecommitdiffstats
path: root/event/example_test.go
blob: 2f47f6f27e4778c2d9f1ace06fcc1615429a9068 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package event

import "fmt"

func ExampleTypeMux() {
    type someEvent struct{ I int }
    type otherEvent struct{ S string }
    type yetAnotherEvent struct{ X, Y int }

    var mux TypeMux

    // Start a subscriber.
    done := make(chan struct{})
    sub := mux.Subscribe(someEvent{}, otherEvent{})
    go func() {
        for event := range sub.Chan() {
            fmt.Printf("Received: %#v\n", event)
        }
        fmt.Println("done")
        close(done)
    }()

    // Post some events.
    mux.Post(someEvent{5})
    mux.Post(yetAnotherEvent{X: 3, Y: 4})
    mux.Post(someEvent{6})
    mux.Post(otherEvent{"whoa"})

    // Stop closes all subscription channels.
    // The subscriber goroutine will print "done"
    // and exit.
    mux.Stop()

    // Wait for subscriber to return.
    <-done

    // Output:
    // Received: event.someEvent{I:5}
    // Received: event.someEvent{I:6}
    // Received: event.otherEvent{S:"whoa"}
    // done
}
polygraph31/Makefile?id=de7b16ac392fa43dd216546ba2d2d0b15e35f36a'>Fix BROKEN by update to latest 2.8.0 version.osa2004-02-271-7/+3 * Mark as broken on 4.x as well as 5.x. No response from maintainerlinimon2004-02-121-2/+0 * Take over maintainership with Dmitry's blessing.adrian2003-07-311-1/+1 cgi/freebsd-ports-gnome/commit/ukrainian?id=9dffa2ed7b6ad215ff0452a549af77ab85b73b7d'>KDE 3.5.4 / KOffice 1.5.2lofi2006-09-1310-30/+24 * All dictionaries can be installed separately:thierry2006-07-154-7/+18 * Update to KDE 3.5.3lofi2006-06-064-16/+16 * Update to KOffice 1.5.1lofi2006-05-276-12/+12 * Update to KOffice 1.5.0lofi2006-04-299-78/+51 * Update to KDE 3.5.2lofi2006-03-314-122/+16 * Update to KDE 3.5.1.lofi2006-02-014-6/+14 * SHA256ifyedwin2006-01-245-0/+5 * Removed not needed distinfo and add empty MASTERSITES and DISTFILES for fix p...anray2006-01-172-3/+2 * Distfile moved to FILESDIR.anray2006-01-172-5/+108 * Update to KDE 3.5.0lofi2006-01-094-110/+68 * KOI8-U coding system for all emacsen.anray2005-12-165-0/+46 * Update to KDE 3.4.3 / KOffice 1.4.2lofi2005-11-052-4/+4 * Remove expired portskris2005-11-0519-3074/+0 * Do the same trick with uk-pine.language as done with ru-pine.languageedwin2005-11-043-8/+41 * Remove all the secondary port of editors/ooodict-allmaho2005-11-012-21/+0 * Fix index build by moving openoffice.org-1.1 ports.maho2005-08-291-1/+1 * Update to KDE 3.4.2 / KOffice 1.4.1lofi2005-08-0110-115/+37 * This port is scheduled for deletion on 2005-09-22 if it is still brokenkris2005-07-232-0/+4 * Update to KDE 3.4.1lofi2005-06-267-17/+6 * - Unbreak and general updatepav2005-06-061-1/+2 * Update to KDE 3.4lofi2005-03-217-66/+233 * BROKEN: Removes config file at deinstall-timekris2005-02-281-0/+2 * BROKEN: Incomplete pkg-plistkris2005-02-191-0/+2 * Add i18nized doc subdirs to kdehier and adjust i18n port plists accordingly.lofi2004-12-235-5/+3 * Tweak IGNORE string to give a better-worded error message.kris2004-12-193-3/+3 * Fix kde3-i18n ports.lofi2004-12-162-4/+4 * Update to KDE 3.3.2lofi2004-12-149-17/+119 * BROKEN on 5.x: Does not compilekris2004-11-191-0/+4 * Update to KDE 3.3.1lofi2004-11-087-12/+32 * Update to KDE 3.3lofi2004-08-3112-15/+17 * Reset maintainer:kris2004-08-161-1/+1 * Pet portlint.lofi2004-07-116-3/+9 * Update to version 3.2.3lofi2004-06-107-16/+27 * Oops. Forgot the language categories.lofi2004-05-076-3/+3 * Update to KDE 3.2.2lofi2004-04-204-32/+22 * Remove category pkg/COMMENT files in favour of a COMMENT variable in thekris2004-04-022-1/+2 * SIZEify (maintainer timeout)trevor2004-03-313-0/+3 * Add ispellkris2004-03-171-0/+1 * Whoa there, boy, that's a mighty big commit y'all have there...ade2004-03-141-3/+3 * Update to KDE 3.2.1 / QT 3.3.1lofi2004-03-109-4/+27 * Use PLIST_FILES (bento-tested, marcus-reviewed).trevor2004-02-062-1/+1 * Update to KDE 3.2.0lofi2004-02-059-54/+136 * Bump PORTREVISION on all ports that depend on gettext to aid with upgrading.marcus2004-02-041-0/+1 * Add USE_GETTEXT and bump PORTREVISION.marcus2004-02-045-10/+10 * - Fix build on 4.xpav2004-01-263-1/+14 * Now gettext 0.12.1 is gettext-old.trevor2004-01-245-5/+5 * - fix PKGORIGINeik2004-01-231-1/+1 * - Update to 5.60pav2004-01-11171-2801/+2714 * Upgrade from 0.5 to 0.7.mi2003-12-102-2/+2 * OpenOffice -> OpenOffice.orgmaho2003-11-091-1/+1 * rename openoffice* to openoffice-1.0* accodingly (repo copy).maho2003-11-081-1/+1 * Mark BROKEN (see bento logs). These ports are scheduled for removalkris2003-11-031-0/+2 * Unbreak BROKEN messageedwin2003-10-131-1/+1 * New port: Ukrainian accounting system. New port of Ukrainian accounting syste...edwin2003-10-10176-0/+3136 * Translation update: fix checksum.will2003-09-222-2/+2 * Upgrade to Qt 3.2.1 / KDE 3.1.4. See x11/kde3/Makefile rev 1.64 for details.will2003-09-182-4/+2 * o Main modificationnork2003-08-191-1/+1 * Update KDE to the latest official release, KDE 3.1.3lofi2003-07-294-6/+16 * Update to KDE 3.1.2lioux2003-05-204-10/+8 * New port: localized messages and documentation for kofficelioux2003-05-2013-0/+208 * Add missing ooodict-uk_UAmbr2003-05-141-0/+1 * Add Ukrainian ooodict.mbr2003-05-141-0/+19 * Rejoice, for the long awaited upgrade to kde 3.1.1 is here!alane2003-04-064-2/+16 * Clear moonlight beckons.ade2003-03-078-4/+4 * De-pkg-comment.knu2003-02-212-1/+1 * De-pkg-comment.knu2003-02-21