This is what my solution does, except that it uses items associated with
priorities instead of 2 channels. if 2 channels are really needed for some
reason, it is easy to adapt the solution to this.
On Fri, May 24, 2019 at 12:12 PM Daniela Petruzalek <
daniela.petruza...@gmail.com> wrote:
> If I
If I had to process messages from both high and low priority channels I
would serialise then with a min heap and create a consumer process for the
min heap. The min heap seems to be the canonical way of solving the
priority queues anyway, so I think it makes sense here.
Basically: goroutine 1
I see an easy* way to implement channel priorities in Go2 if that is
desired.
two steps:
step 2: At lines 124 and 153-157 of src/runtime/select.go, an *order of
channel testing* index table is created, then permuted.
It is later visited in order. All that needs doing is to make the index
table
On Fri, May 24, 2019 at 1:50 AM roger peppe wrote:
> On Thu, 23 May 2019 at 19:28, Bruno Albuquerque wrote:
>
>> This was my attempt at a channel with priorities:
>>
>>
>> https://git.bug-br.org.br/bga/channels/src/master/priority/channel_adapter.go
>>
>> Based on the assumption that priorities
On Fri, May 24, 2019 at 8:40 AM roger peppe wrote:
> On Fri, 24 May 2019 at 16:25, Bruno Albuquerque wrote:
>
>> On Fri, May 24, 2019 at 1:50 AM roger peppe wrote:
>>
>>> On Thu, 23 May 2019 at 19:28, Bruno Albuquerque wrote:
>>>
This was my attempt at a channel with priorities:
On Fri, 24 May 2019 at 16:25, Bruno Albuquerque wrote:
> On Fri, May 24, 2019 at 1:50 AM roger peppe wrote:
>
>> On Thu, 23 May 2019 at 19:28, Bruno Albuquerque wrote:
>>
>>> This was my attempt at a channel with priorities:
>>>
>>>
>>>
On Thu, 23 May 2019 at 19:28, Bruno Albuquerque wrote:
> This was my attempt at a channel with priorities:
>
>
> https://git.bug-br.org.br/bga/channels/src/master/priority/channel_adapter.go
>
> Based on the assumption that priorities only make sense if items are
> queued. If they are pulled out
Good point i'll update with a timeout to flush in case traffic is slow
On Thu, May 23, 2019 at 1:38 AM roger peppe wrote:
> On Thu, 23 May 2019 at 01:34, Anthony Metzidis
> wrote:
>
>> Fun thought exercise -- here's another approach.
>>
>>
>> https://play.golang.org/p/Xu7iWhY4PUQ
>>
>
> ISTM
This was my attempt at a channel with priorities:
https://git.bug-br.org.br/bga/channels/src/master/priority/channel_adapter.go
Based on the assumption that priorities only make sense if items are
queued. If they are pulled out from a channel as fast as they are added to
it, then there is no
Oops, forgot to include the playground link at the end there:
https://play.golang.org/p/mYSRsGb4mRA
On Thu, 23 May 2019 at 09:38, roger peppe wrote:
> On Thu, 23 May 2019 at 01:34, Anthony Metzidis
> wrote:
>
>> Fun thought exercise -- here's another approach.
>>
>>
>>
On Thu, 23 May 2019 at 01:34, Anthony Metzidis
wrote:
> Fun thought exercise -- here's another approach.
>
>
> https://play.golang.org/p/Xu7iWhY4PUQ
>
ISTM that that approach doesn't work because you're buffering 10 values
before you send any.
So if you have a situation when you've got very
Fun thought exercise -- here's another approach.
https://play.golang.org/p/Xu7iWhY4PUQ
package main
import (
"fmt"
"math/rand"
"sort"
"time"
"strconv"
)
type PriorityStruct struct {
Pint
name string
}
const BUFSIZE = 10
type PriorityChan chan PriorityStruct
type PriorityBuf
Would this work?
select {
case val := <-high:
continue
default:
}
select {
case val := <-high:
case val := <-high:
case val := <-high:
case val := <-low:
}
On Monday, July 23, 2012 at 2:16:16 PM UTC-7, Erwin wrote:
>
> Hello,
>
> i wonder how to implement channel priorities nicely. Say there
select {
case highVal := <- high:
case lowVal := <- low:
if len(high) > 0 {
for len(high) > 0 {
highVal := <- high
}
}
// process lowVal
}
On Tuesday, July 24, 2012 at 5:16:16 AM UTC+8, Erwin Driessens wrote:
>
> Hello,
>
>
14 matches
Mail list logo