On Thu, Apr 14, 2022 at 3:28 PM I wrote:
> Conceptually, the debug thread mechanism could be hijacked as a
> synchronization mechanism.

At least in j904 beta b, this approach has a severe practical problem.
Here's an illustration of the underlying mechanics:

NB. ensure we have some threads
0&T.@'' each i.0>.4-1 T.''

NB. use a couple threads
{{6!:3 y if.1 do.echo y end.}} t.''"0] 10 11

NB. sync
13!:0]1
13!:15'joinImplementation 0'

joinImplementation=: {{
  NB. synchronization mechanism would go here
  echo '-------------'
  echo '1 ',":1 T.''
  echo '2 ',":2 T.''
  echo '3 ',":3 T.''
  echo 13!:1''
  echo '-------------'
  13!:5''
}}

test=: {{
  echo 'a'
  assert. 0
  echo 'b'
}}

test''

When I run this script, I expected my debug latent expression to run
immediately. Instead, it does not run until all tasks have completed
their work. This behavior was not intended, if I understood correctly.

Additionally, the 13!:5'' does not resume execution -- I can work
around this by replacing that line with   9!:27'13!:5'''''[9!:29]1 so
that's less of an issue for now.

That said, my vision here was to define a 'sync' adverb which takes a
y argument, stores it in a task specific variable, and then uses
assert. to enter the debug sentence. The debug sentence would
recognize that 'sync' was used and would pick up the thread's y value
and execute u against it. I have not figured out how to read the debug
thread number, however, so I would have to inject that information
into the stack trace, and pull it out of the 13!:13'' result.

But... as you can see... this would be rather slow in beta b.

FYI,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to