• Threading or timer functi

    From Nightfox@VERT/DIGDIST to Digital Man on Fri Feb 4 14:17:00 2011
    Hi DM -

    In one of my JS scripts for Synchronet, there is something that I would like to have happen periodically. It's something that could be handled using JavaScript's setInterval() function, but it appears that function is not available in Synchronet's JS. I looked through the documentation (jsobjs.html) for something related to timers or threads but didn't see an equivalent there.

    I did see the queue class, which mentions that it's used for inter-thread/module communications, but I didn't see any functions for running something in a separate thread. The closest I could think of, looking at the docs, is to use load() to load & execute another JS script in the background - is there a better way to do it?

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS: digdist.bbsindex.com
  • From Digital Man@VERT to Nightfox on Mon Feb 7 10:10:00 2011
    Re: Threading or timer functions
    By: Nightfox to Digital Man on Fri Feb 04 2011 07:17 pm

    Hi DM -

    In one of my JS scripts for Synchronet, there is something that I would
    like to have happen periodically. It's something that could be handled using JavaScript's setInterval() function, but it appears that function is not available in Synchronet's JS. I looked through the documentation (jsobjs.html) for something related to timers or threads but didn't see an equivalent there.
    I did see the queue class, which mentions that it's used for inter-thread/module communications, but I didn't see any functions for running something in a separate thread. The closest I could think of, looking at the docs, is to use load() to load & execute another JS script
    in the background - is there a better way to do it?

    load(true,...) is the only way to start background thread. For something to happen periodically, that's probably not the best way to achieve that. Instead, have a main loop (e.g. watching for keyboard input or whatever is equivalent for your script) and have it periodically perform the desired task based on the elapsed time.

    digital man

    Snapple "Real Fact" #67:
    There are 18 different animal shapes in the Animal cracker zoo.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Nightfox@VERT/DIGDIST to Digital Man on Mon Feb 7 14:28:00 2011
    Re: Threading or timer functions
    By: Digital Man to Nightfox on Mon Feb 07 2011 15:10:24

    load(true,...) is the only way to start background thread. For something to happen periodically, that's probably not the best way to achieve that. Inste have a main loop (e.g. watching for keyboard input or whatever is equivalent for your script) and have it periodically perform the desired task based on elapsed time.

    Thanks.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS: digdist.bbsindex.com