For jconsole applications that have no UI, the infinite loop can emulate an
inaccurate timer,

while 1[usleep 20000 do.  NB. 0.02s
dotask1''
dotask2''
...
end.

where usleep is (beware of wrapping)

NB. =========================================================
NB. *usleep v sleep for n microseconds
NB. linux max value around 33 minutes
NB. windows minimum resolution in milliseconds.
3 : 0''
if. 'Linux'-:UNAME do. usleep=: 3 : '''libc.so.6 usleep > i i''&(15!:0) >.y'
elseif. 'Darwin'-:UNAME do. usleep=: 3 : '''libc.dylib usleep > i i''&(15!:0) 
>.y'
elseif. do. usleep=: 3 : '0: ''kernel32 Sleep > n i''&(15!:0) >.y % 1000'
end.
EMPTY
)

But I guess this method does not work with jhs yet, the javascript timer as
suggested by Eric should be more compatibile with jhs.

For gtk, timer is already supported, please refer to plot demo or opengl
demo. (grep for the word 'timeout')

Чтв, 05 Янв 2012, Ian Clark писал(а):
> > Ian - a good place to study j use of dylib in Darwin would be in
> > ~/addons/data/jmf.ijs  Maybe you can find happiness there.
> 
> Now that looks sensible!
> 
> Searching the code for 'dylib' I learn that cd (15!:0) can access
> dylibs, here mostly libc.dylib, just like it does in Windows (with of
> course a different argument syntax). Why didn't I spot that before?
> Now I just need to brush up my knowledge of the standard C library
> (=libc). A simple matter of wading thru the Xcode documentation.
> 
> > Meanwhile, I'm a little unclear on what you are trying to do.
> 
> Let me try to explain as briefly as I can.
> 
> I have a bunch of j602 apps with fine-tuned jwd UIs which I want to
> migrate to j7. Including a few cherished app dev utilities. "Oh, just
> rewrite them all in jgtk" ... sounds plausible if you say it quickly.
> 
> I reasoned, as a first step: if I can split off the jwd UI to run in
> an asynchronous process communicating via a link that's both general
> and docile, then that's half the battle. I can then replace the UIs at
> my leisure with ones written in Cocoa / Xcode -- or jgtk -- or
> html/javascript... you name it. Perhaps all of these, for a
> distributed app. The now-faceless apps will like-as-not run unchanged
> under J7, as "servers", and they'll even work with their old j601 UIs,
> while I develop plug-compatible replacements. That's if I feel the
> urge to.
> 
> Well, I'm pleased to report I can now split even a complex jwd app
> into client+server, without having to re-engineer the app's UI (too
> much). My lo-tech link is sweet and docile: you can interact with both
> client and server via their J sessions and you hardly realise they're
> alive and talking to each other. A wiki case-study will follow
> shortly.
> 
> But... my technique doesn't port readily to j7 because of one thing:
> no wd'timer'.
> 
> Actually this isn't such a show-stopper as I'm making out. I can
> always run my "server" duty-cycle instead in a tight loop, as you do
> yours (...6!:3 is "tight" to me :). The back-end of the app, I reason,
> will not need that much debugging by now, and I can do most of that
> back in my cosy j602 environment. But I've got mighty used to the
> elbow-room that wd'timer' affords me.
> 
> On Thu, Jan 5, 2012 at 7:13 PM, Joey K Tuttle <j...@qued.com> wrote:
> > Ian - a good place to study j use of dylib in Darwin would be in
> > ~/addons/data/jmf.ijs  Maybe you can find happiness there.
> >
> > Meanwhile, I'm a little unclear on what you are trying to do. I assume
> > you have a continuously available j task that picks up things to do from
> > some queue - but you don't want it to be in a dead loop checking the
> > queue. I run a task like that in my Linux server and it has the lines:
> >
> >    while. * 6!:3 ] 1 do.
> >        if. (work to do) do.
> >            massage some data (actually quite a lot... but sporadic)
> >        end.
> >    end.
> >
> > This task runs as a #! jconsole shell and I just looked to see that it
> > has been running for 100 days and has accumulated 20 minutes and 15
> > seconds of CPU time (on a 400 Mhz pentium - so pretty small overhead).
> > Of course, the CPU usage is dependent on the work that gets done - but
> > since (as you pointed out in a different message) j is single threaded,
> > this seems to me to be a way to approach the kind of thing you seem to
> > be describing.
> >
> > On 2012/01/05 09:54 , Ian Clark wrote:
> >> Thanks, David.
> >>
> >> But this uses 'dll'. AFAIK there's no comparable way of calling dylibs
> >> in Darwin.
> >>
> >> On Thu, Jan 5, 2012 at 5:44 PM, David Mitchell<davidmitch...@att.net>  
> >> wrote:
> >>> Here is a version that works with J602 and J701 jconsole.  It does not 
> >>> work with
> >>> jhs or jgtk.  I have not tested it extensively and it may have side 
> >>> effects or
> >>> bugs that I haven't found yet.
> >>>
> >>> http://www.jsoftware.com/jwiki/Scripts/WindowsTimer
> >>>
> >>> On 1/5/2012 8:27, Ian Clark wrote:
> >>>> How do I get a timer in j701 jhs (or jconsole)?
> >>>>
> >>>> I've been assuming wd (11!:0) doesn't work at all in j701 (in j602
> >>>> you'd do: 11!:0 'timer 3' for a callback in 3 secs).
> >>>>
> >>>> BTW J701 help 
> >>>> (http://www.jsoftware.com/docs/help701/dictionary/dx011.htm)
> >>>> still refers to 11!:0 but I assume that's just because it's been
> >>>> overlooked...?
> >>>>
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to