File tree 6 files changed +16
-16
lines changed
6 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 1
- # Concurrent ordered processing
1
+ # Ordered Fan-In
2
2
You can use this ` oproc ` package when you want to speed up processing with goroutines
3
3
while guaranteeing ordering.
4
4
@@ -13,14 +13,14 @@ import (
13
13
" math/rand"
14
14
" time"
15
15
16
- " github.com/sjnam/oproc "
16
+ " github.com/sjnam/ofanin "
17
17
)
18
18
19
19
func main () {
20
20
ctx , cancel := context.WithCancel (context.TODO ())
21
21
defer cancel ()
22
22
23
- my := oproc. NewOrderedProc [string /* input param*/ , string /* output param*/ ](ctx)
23
+ my := ofanin. NewOrderedFanIn [string /* input param*/ , string /* output param*/ ](ctx)
24
24
my.InputStream = func () <- chan string {
25
25
ch := make (chan string )
26
26
go func () {
Original file line number Diff line number Diff line change 7
7
"log"
8
8
"net/http"
9
9
10
- "github.com/sjnam/oproc "
10
+ "github.com/sjnam/ofanin "
11
11
)
12
12
13
13
type item struct {
@@ -26,7 +26,7 @@ func main() {
26
26
ctx , cancel := context .WithCancel (context .TODO ())
27
27
defer cancel ()
28
28
29
- my := oproc. NewOrderedProc [item /*input param*/ , item /*output param*/ ](ctx )
29
+ my := ofanin. NewOrderedFanIn [item /*input param*/ , item /*output param*/ ](ctx )
30
30
my .InputStream = func () <- chan item {
31
31
valStream := make (chan item )
32
32
go func () {
Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ import (
6
6
"math/rand"
7
7
"time"
8
8
9
- "github.com/sjnam/oproc "
9
+ "github.com/sjnam/ofanin "
10
10
)
11
11
12
12
func main () {
13
13
ctx , cancel := context .WithCancel (context .TODO ())
14
14
defer cancel ()
15
15
16
- my := oproc. NewOrderedProc [string /*input param*/ , string /*output param*/ ](ctx )
16
+ my := ofanin. NewOrderedFanIn [string /*input param*/ , string /*output param*/ ](ctx )
17
17
my .InputStream = func () <- chan string {
18
18
ch := make (chan string )
19
19
go func () {
Original file line number Diff line number Diff line change 1
- module github.com/sjnam/oproc
1
+ module github.com/sjnam/ofanin
2
2
3
3
go 1.23.4
Original file line number Diff line number Diff line change 1
- package oproc
1
+ package ofanin
2
2
3
3
import (
4
4
"context"
5
5
"runtime"
6
6
)
7
7
8
- type OrderedProc [TI /*input param type*/ , TO /*output param type*/ any ] struct {
8
+ type OrderedFanIn [TI /*input param type*/ , TO /*output param type*/ any ] struct {
9
9
Ctx context.Context
10
10
InputStream <- chan TI
11
11
DoWork func (TI ) TO
12
12
Size int
13
13
}
14
14
15
- func NewOrderedProc [TI , TO any ](ctx context.Context ) * OrderedProc [TI , TO ] {
16
- return & OrderedProc [TI , TO ]{
15
+ func NewOrderedFanIn [TI , TO any ](ctx context.Context ) * OrderedFanIn [TI , TO ] {
16
+ return & OrderedFanIn [TI , TO ]{
17
17
Ctx : ctx ,
18
18
Size : runtime .NumCPU (),
19
19
}
20
20
}
21
21
22
- func (o * OrderedProc [TI , TO ]) Process () <- chan TO {
22
+ func (o * OrderedFanIn [TI , TO ]) Process () <- chan TO {
23
23
orDone := func (c <- chan TO ) <- chan TO {
24
24
ch := make (chan TO )
25
25
go func () {
Original file line number Diff line number Diff line change 1
- package oproc
1
+ package ofanin
2
2
3
3
import (
4
4
"context"
5
5
"fmt"
6
6
)
7
7
8
- func ExampleOrderedProc () {
8
+ func ExampleOrderedFanIn () {
9
9
ctx , cancel := context .WithCancel (context .TODO ())
10
10
defer cancel ()
11
11
12
- my := NewOrderedProc [string /*input param*/ , string /*output param*/ ](ctx )
12
+ my := NewOrderedFanIn [string /*input param*/ , string /*output param*/ ](ctx )
13
13
my .InputStream = func () <- chan string {
14
14
ch := make (chan string )
15
15
go func () {
You can’t perform that action at this time.
0 commit comments