Selaa lähdekoodia

core/sync/chan.try_select_raw: skip nil input messages

This makes the proc easier and safer to call by letting the caller nil
out messages to skip sends.
Jack Mordaunt 3 kuukautta sitten
vanhempi
commit
4043be8567
1 muutettua tiedostoa jossa 4 lisäystä ja 1 poistoa
  1. 4 1
      core/sync/chan/chan.odin

+ 4 - 1
core/sync/chan/chan.odin

@@ -1205,7 +1205,10 @@ try_select_raw :: proc "odin" (recvs: []^Raw_Chan, sends: []^Raw_Chan, send_msgs
 		}
 
 		for c, i in sends {
-			if can_send(c) {
+			if i > builtin.len(send_msgs)-1 || send_msgs[i] == nil {
+				continue
+			}
+			if can_send(c)  {
 				candidates[count] = {
 					is_recv = false,
 					idx     = i,