r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Rebol School] Rebol School

Graham
4-Jan-2009
[1304x2]
Gregg ... it's supposed to be real time .. push a button and see 
the graph.  I guess this is the same as Steeve suggests .. wait until 
the results come in, or timeout ...
I guess I should try and keep it simple vs trying to chain all the 
callbacks somehow.
Gregg
5-Jan-2009
[1306]
If you can render the graph with partial data, do it each time data 
comes in, or set up a rendering callback that the data callback calls. 
Polling intervals (if needed) can be pretty short without burning 
the CPU. If it's on the net, there's no guarantee of real time. :-)
Graham
5-Jan-2009
[1307x2]
That's a thought ... it's on localhost ...
the rendering is in a browser ... so that's not going to work unfortunately 
as I can't make the browser refresh.
BrianH
5-Jan-2009
[1309]
...without javascript or refresh tags...
Graham
5-Jan-2009
[1310]
The problem then shifts to determining how to make the browser only 
refresh when there is new data.
Maxim
5-Jan-2009
[1311x2]
ajax
;-)
Graham
5-Jan-2009
[1313]
The data is being generated as json, and loaded  into an ajax widget 
when the page is first rendered.
Maxim
5-Jan-2009
[1314]
you can just to a small ping to detect changes... it can even be 
a boolean request, thus really tiny and fast.
Graham
5-Jan-2009
[1315]
example?
Maxim
5-Jan-2009
[1316x3]
I haven't done it myself, but where I used to work, the guy would 
put an invisible div with a refresh rate on it. and the contents 
was dynamic, whenever changes occured it triggered the calls for 
the other divs on the page.
something along those lines... I can't explain in better details. 
 that was like 4 years ago... but surely there are plenty of examples 
on the net not?  gmail does it.
maybe you can look into its code?  using firebug, you should be able 
to read the dynamic javascript it downloads.
Graham
5-Jan-2009
[1319]
Using javascript to solve a rebol programming problem :)
Maxim
5-Jan-2009
[1320x2]
heheheh
well... isn't it a web problem?   the browser ...  yuk.
Graham
5-Jan-2009
[1322x3]
No, it's a Rebol problem.
If I used a different way of rendering the graph, I have the same 
problem back again.
So, I need to solve it at the REBOL side.
Maxim
5-Jan-2009
[1325]
but you can render within a rebol client?
Graham
5-Jan-2009
[1326]
I think I'll have a go at my first idea which was to create a stack 
of functions
Maxim
5-Jan-2009
[1327x3]
if you can do it within view... then you problem seems pretty simple 
to me... I did a 4 way async system with on-demand buttons, loading 
data from the net and bg transfers syncing all running clients with 
a central cerver.
one of the threads was using google as a meta-engine.
so... can the graph data be viewed within a rebol window?
Graham
5-Jan-2009
[1330x3]
no
yes ..
the data only ... not the graph
Maxim
5-Jan-2009
[1333x3]
using gabriel's async (fixed for close port bug ) I built an async 
xfer context.
each context had an init, a buffer collection and an on-close event 
.
(on close function)
Graham
5-Jan-2009
[1336]
So, how did you know when all the data was collected?
Maxim
5-Jan-2009
[1337x7]
and I used a simple face timer to poll through the async contexts 
to see if the xfer was finished.  then call the on-close event. and 
remove it from the list of "pending" xfers.
in the async port, you can react to the close port event directly.
so I would just do

done?: true
and the polling would immediately call the on-close
using view's port stack, instead of the network stack which was effectively 
closed by then.
view's port event stack
I set the face timer to 30 times a second, and really.... cpu useage 
was at 0% on my system.
Graham
5-Jan-2009
[1344]
presumably when one transfer finishes, it could check the others 
and then render if they were all finished.  Do I need to poll?
Maxim
5-Jan-2009
[1345x2]
the checkup loop was something like


you can do it that way too... but you might get into some strange 
stack issues, cause you end up handling  port messages from one port 
to another within the messaging stack... but I guess a simple test 
sould suffice to see if its stable or not.


in my case, the gui had to stay responsive, since the xfer-contexts 
had cancel methods, which interrupted any xfer in real-time, and 
the whole gui had to still handle events smoothly, like scrolling 
a huge list, while it was adding items to that list, as it parsed 
the return value from the google search engine  :-)
oops  hehe missing some lines there...
Graham
5-Jan-2009
[1347]
Does seem straight forward when you explain it like that :)
Maxim
5-Jan-2009
[1348x3]
you verification could be something like:

unless all [ctx1/done? ctx2/done? ...] [ 
	;all done, do whatever
]
or using an integer with bit handling, it could be as simple as 

; a four bit setup
unless done-bits = 7 [
]
and to set individual "done" bits

xfer-context: [
  set-done: does[ 
     done-bits: done-bits OR power 2 index? find port-list self
  ]
]

:-)
Steeve
5-Jan-2009
[1351x2]
usualy, when dealing with bits, it's better to use bitset!, all operations 
are faster (insertion, modification, search)
i noted that bitset! are mostly under rated by rebolers
Graham
5-Jan-2009
[1353]
I think it's about language compactness.