Browse Source

core/sync/chan.try_select_raw: clarify loop control flow

Use a label to clarify the continue statements.
Jack Mordaunt 3 months ago
parent
commit
fb39e5a2f8
1 changed files with 4 additions and 3 deletions
  1. 4 3
      core/sync/chan/chan.odin

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

@@ -1125,6 +1125,7 @@ and which are available for sending. It then randomly selects one operation
 If no channels have messages ready, the procedure is a noop.
 If no channels have messages ready, the procedure is a noop.
 
 
 Note: Each message in `send_msgs` corresponds to the send channel at the same index in `sends`.
 Note: Each message in `send_msgs` corresponds to the send channel at the same index in `sends`.
+If the message is nil, corresponding send channel will be skipped.
 
 
 **Inputs**
 **Inputs**
 - `recv`: A slice of channels to read from
 - `recv`: A slice of channels to read from
@@ -1190,7 +1191,7 @@ try_select_raw :: proc "odin" (recvs: []^Raw_Chan, sends: []^Raw_Chan, send_msgs
 	candidate_count := builtin.len(recvs)+builtin.len(sends)
 	candidate_count := builtin.len(recvs)+builtin.len(sends)
 	candidates := ([^]Select_Op)(intrinsics.alloca(candidate_count*size_of(Select_Op), align_of(Select_Op)))
 	candidates := ([^]Select_Op)(intrinsics.alloca(candidate_count*size_of(Select_Op), align_of(Select_Op)))
 
 
-	for {
+	try_loop: for {
 		count := 0
 		count := 0
 
 
 		for c, i in recvs {
 		for c, i in recvs {
@@ -1223,12 +1224,12 @@ try_select_raw :: proc "odin" (recvs: []^Raw_Chan, sends: []^Raw_Chan, send_msgs
 		if sel.is_recv {
 		if sel.is_recv {
 			status = .Recv
 			status = .Recv
 			if !try_recv_raw(recvs[sel.idx], recv_out) {
 			if !try_recv_raw(recvs[sel.idx], recv_out) {
-				continue
+				continue try_loop
 			}
 			}
 		} else {
 		} else {
 			status = .Send
 			status = .Send
 			if !try_send_raw(sends[sel.idx], send_msgs[sel.idx]) {
 			if !try_send_raw(sends[sel.idx], send_msgs[sel.idx]) {
-				continue
+				continue try_loop
 			}
 			}
 		}
 		}