I don't think cdcb can help you to implement event loop or similar
functions. cdcb is very restricted. the callback must happen within the
context of the call that passed the callback address. Theoretically
external codes can invoke the callback, but since J is single threaded and
has no event loop, therefore callback has no chance of being called. If you
run J in a separate thread, you will be responsible to handle cross thread
communication.

On Mon, Nov 30, 2020, 5:22 PM emacstheviking <[email protected]> wrote:

> I found the Lab on cdcallback and followed it, I did the qsort version and
> it all works as described but applying it to my SDL application I got this
> as soon as the timer kicks in, I tried different timer values to ensure it
> was related:
>
> timerid:1
> |stack error: sdl_renderpresent
> |       sdl_renderpresent appr
>
> My callback is as simple as they come as I wanted to remove any doubts
> about cross-thread corruption, I assumed therefore that this implementation
> would not cause any great upset:
>
> cdcallback =: 3 : 0
> 0
> )
>
> So I think that cdcallback only works when in the same thread (did I miss
> that in the lab?) i.e. the main thread as obviously id SDL is creating a
> fork() call somewhere then there is likely to be some issue with stacks,
> environments etc etc etc
>
> I will dig a little more but the stack error means the stack was exhausted,
> typically due to recursion. I checked the J source code for EVSTACK ("stack
> error") and it seemed reasonable so I am guessing that the SDL context
> switch derailed the J engine in its tracks.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to