mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 18:52:44 +01:00
Revert "thread: Close channels"
This reverts commit 00e78c1eae
.
Reason: (*Thread).Loop can be called multiple times on iOS.
Fixes #1121
This commit is contained in:
parent
a9c74e48e1
commit
41d07706ae
@ -22,7 +22,6 @@ import (
|
|||||||
type Thread struct {
|
type Thread struct {
|
||||||
funcs chan func() error
|
funcs chan func() error
|
||||||
results chan error
|
results chan error
|
||||||
closed chan struct{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new thread.
|
// New creates a new thread.
|
||||||
@ -32,7 +31,6 @@ func New() *Thread {
|
|||||||
return &Thread{
|
return &Thread{
|
||||||
funcs: make(chan func() error),
|
funcs: make(chan func() error),
|
||||||
results: make(chan error),
|
results: make(chan error),
|
||||||
closed: make(chan struct{}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,9 +38,6 @@ func New() *Thread {
|
|||||||
//
|
//
|
||||||
// Loop must be called on the thread.
|
// Loop must be called on the thread.
|
||||||
func (t *Thread) Loop(context context.Context) {
|
func (t *Thread) Loop(context context.Context) {
|
||||||
defer close(t.closed)
|
|
||||||
defer close(t.results)
|
|
||||||
defer close(t.funcs)
|
|
||||||
loop:
|
loop:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -60,10 +55,6 @@ loop:
|
|||||||
//
|
//
|
||||||
// Call panics when Loop already ends.
|
// Call panics when Loop already ends.
|
||||||
func (t *Thread) Call(f func() error) error {
|
func (t *Thread) Call(f func() error) error {
|
||||||
select {
|
t.funcs <- f
|
||||||
case t.funcs <- f:
|
return <-t.results
|
||||||
return <-t.results
|
|
||||||
case <-t.closed:
|
|
||||||
panic("thread: this thread is already terminated")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user