diff options
author | Ayke van Laethem <[email protected]> | 2019-05-04 21:32:00 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-05-05 16:46:50 +0200 |
commit | 9a54ee4241a1ec252368eb7e7576a5b41723beec (patch) | |
tree | 15560a6ed4666a30b0281d4b0888aaff786874ff /testdata/channel.go | |
parent | 46d5ea8cf6bffd3606d64b7404656a51394b10aa (diff) | |
download | tinygo-9a54ee4241a1ec252368eb7e7576a5b41723beec.tar.gz tinygo-9a54ee4241a1ec252368eb7e7576a5b41723beec.zip |
compiler: allow larger-than-int values to be sent across a channel
Instead of storing the value to send/receive in the coroutine promise,
store only a pointer in the promise. This simplifies the code a lot and
allows larger value sizes to be sent across a channel.
Unfortunately, this new system has a code size impact. For example,
compiling testdata/channel.go for the BBC micro:bit, there is an
increase in code size from 4776 bytes to 4856 bytes. However, the
improved flexibility and simplicity of the code should be worth it. If
this becomes an issue, we can always refactor the code at a later time.
Diffstat (limited to 'testdata/channel.go')
-rw-r--r-- | testdata/channel.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/testdata/channel.go b/testdata/channel.go index 840255911..e3b8aed36 100644 --- a/testdata/channel.go +++ b/testdata/channel.go @@ -20,6 +20,11 @@ func main() { n, ok = <-ch println("recv from closed channel:", n, ok) + // Test bigger values + ch2 := make(chan complex128) + go sendComplex(ch2) + println("complex128:", <-ch2) + // Test multi-sender. ch = make(chan int) go fastsender(ch) @@ -62,6 +67,10 @@ func sender(ch chan int) { close(ch) } +func sendComplex(ch chan complex128) { + ch <- 7+10.5i +} + func fastsender(ch chan int) { ch <- 10 ch <- 11 |