mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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 {
|
||||
funcs chan func() error
|
||||
results chan error
|
||||
closed chan struct{}
|
||||
}
|
||||
|
||||
// New creates a new thread.
|
||||
@ -32,7 +31,6 @@ func New() *Thread {
|
||||
return &Thread{
|
||||
funcs: make(chan func() error),
|
||||
results: make(chan error),
|
||||
closed: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,9 +38,6 @@ func New() *Thread {
|
||||
//
|
||||
// Loop must be called on the thread.
|
||||
func (t *Thread) Loop(context context.Context) {
|
||||
defer close(t.closed)
|
||||
defer close(t.results)
|
||||
defer close(t.funcs)
|
||||
loop:
|
||||
for {
|
||||
select {
|
||||
@ -60,10 +55,6 @@ loop:
|
||||
//
|
||||
// Call panics when Loop already ends.
|
||||
func (t *Thread) Call(f func() error) error {
|
||||
select {
|
||||
case t.funcs <- f:
|
||||
return <-t.results
|
||||
case <-t.closed:
|
||||
panic("thread: this thread is already terminated")
|
||||
}
|
||||
t.funcs <- f
|
||||
return <-t.results
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user