-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.go
60 lines (58 loc) · 1.5 KB
/
doc.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Tideland Go Actor
//
// Copyright (C) 2019-2023 Frank Mueller / Tideland / Oldenburg / Germany
//
// All rights reserved. Use of this source code is governed
// by the new BSD license.
// Package actor supports the simple creation of concurrent applications
// following the idea of actor models. The work to be done has to be defined
// as func() inside your public methods or functions and sent to the actor
// running in the background.
//
// type Counter struct {
// counter int
// act *actor.Actor
// }
//
// func NewCounter() (*Counter, error) {
// act, err := actor.Go()
// if err != nil {
// return nil, err
// }
// c := &Counter{
// counter: 0,
// act: act,
// }
// // Increment the counter every second.
// interval := 1 * time.Second
// c.act.Repeat(interval, func() {
// c.counter++
// })
// return c, nil
// }
//
// func (c *Counter) Incr() error {
// return c.act.DoAsync(func() {
// c.counter++
// })
// }
//
// func (c *Counter) Get() (int, error) {
// var counter int
// if err := c.act.DoSync(func() {
// counter = c.counter
// }); err != nil {
// return 0, err
// }
// return counter, nil
// }
//
// func (c *Counter) Stop() {
// c.act.Stop()
// }
//
// The options for the constructor allow to pass a context for the Actor, the capacity
// of the Action queue, a recoverer function in case of an Action panic and a finalizer
// function when the Actor stops.
package actor // import "tideland.dev/go/actor"
// EOF