Skip to content

Commit b5b9fae

Browse files
author
Dorian Birraux
committed
Use SocketListen to evaluate message
1 parent edcc056 commit b5b9fae

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

wolframclient/evaluation/kernel/initkernel.m

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@
188188
$MaxIdlePause=.001;
189189
$MinIdlePause=0.0001;
190190
$PauseIncrement=0.0001;
191-
$TaskSupportMinVersion = Infinity;
191+
$ListenerSupportMinVersion = 12.3;
192192

193193
Which[
194-
$VersionNumber < $TaskSupportMinVersion,
194+
$VersionNumber < $ListenerSupportMinVersion,
195195
(* Low CPU wait but need synchronous loop. *)
196196
evaluationLoop[socketIn_SocketObject]:= With[
197197
{maxPause=$MaxIdlePause, minPause=$MinIdlePause, incr=$PauseIncrement, poller={socketIn}},
@@ -208,7 +208,16 @@
208208
]
209209
],
210210
True,
211-
(* Version with fixed asynchronous tasks *)
211+
evaluationLoop[socketIn_SocketObject]:= (
212+
$SocketListener = SocketListen[
213+
socketIn,
214+
socketEventHandler[#DataByteArray]&
215+
];
216+
SendAck[];
217+
Pause[2^60];
218+
);
219+
(*
220+
Version with fixed asynchronous tasks
212221
evaluationLoop[socketIn_SocketObject]:= With[
213222
{maxPause=$MaxIdlePause, minPause=$MinIdlePause, incr=$PauseIncrement, poller={socketIn}},
214223
$Task = SessionSubmit[
@@ -221,24 +230,25 @@
221230
SocketWaitNext[poller];
222231
]
223232
),
224-
0.0001 (*negligeable compared to IO operations ~1ms. We basically need 0 but can't use this value. *)
233+
0.0001 negligeable compared to IO operations ~1ms. We basically need 0 but can't use this value.
225234
],
226235
Method->"Idle",
227236
HandlerFunctions-><|"TaskStarted"->SendAck[]|>
228237
];
229238
];
239+
*)
230240
];
231241
(* can be useful for loopback connections which are available only if a task can be used.
232242
Does not kill the kernel *)
233243
ClientLibrary`disconnect[] := Quit[];
234-
ClientLibrary`disconnect[] /; ($Task =!= None) := (
235-
TaskRemove[$Task];
244+
ClientLibrary`disconnect[] /; ($SocketListener =!= None) := (
245+
DeleteObject[$SocketListener];
236246
Scan[
237247
If[# =!= None, Close[#]] &,
238248
{$LoggerSocket, $OutputSocket, $InputSocket}
239249
]
240250
);
241-
$Task = None;
251+
$SocketListener = None;
242252
$LoggerSocket=None;
243253
$OutputSocket=None;
244254
$InputSocket=None;

0 commit comments

Comments
 (0)