Computer Games Forum
 

Go Back   Computer Games Forum > Tech > The Workshop > Limbaje de programare

Notices

Căutare produse PC Garage: Şterge căutarea

Reply
 
LinkBack Thread Tools
Old 16-04-2008, 13:34   #1 (permalink)
75% apa
 
Doctor Bonez's Avatar
 
Join Date: Feb 1999
[Java] Background caching thread

Se da un program in Java care, in momentul in care este rulat, incarca o cantitate semnificativa de date sub forma unei ierarhii (categorii principale, secundare, tertiare).

In starea actuala, programul "ingheata" pana termina de incarcat tot. Ma intereseaza ca, in momentul in care a terminat de citit categoriile principale, programul sa le afiseze si sa continue incarcarea subcategoriilor "in background". Mai exact, userul sa poata vedea categoriile principale, si in momentul in care da click pe una dintre ele, daca nu s-a terminat cashing-ul, sa astepte pana acesta se termina.

[edit]: Probabil e important de mentionat ca interfata cu utilizatorul nu e Swing, ci JSP...
__________________
Nashpa...

"In the beginning the Universe was created. This has made a lot of people very angry
and been widely regarded as a bad move." (Douglas Adams)

 
Doctor Bonez is offline    Reply With Quote
Old 16-04-2008, 15:38   #2 (permalink)
Subterranean infiltrator
 
Karg's Avatar
 
Join Date: Apr 1999
e cam greu de dezvoltat o explicatie precisa avind in vedere ca nu stiu metodele de implementare, dar, generic vorbind - ne-legat de limbaj - as face cam asa:
- ar trebui sa folosesti ceva conceptual asemanator cu un proxy (design pattern), conectat cu un observer;
- pp ca tree'ul tau e un control TTree care contine o ierarhie de TTreeNode;
- ai o clasa de background/thread loading, TThreadLoader
- derivezi din TTreeNode un TTreeNodeCache; acest TTreeNodeCache va fi observer la TThreadLoader; cind incarcarea e gata, TThreadLoader va notifica fiecare TTreeNodeCache

toata explicatia merge daca poti sa creezi ierarhia de TTreeNodeCache fara sa citesti datele; daca nu se poate, atunci...urmeaza alta explicatie.
__________________
red birds will fly out of the east and destroy paris in a night
 
Karg is offline    Reply With Quote
Old 16-04-2008, 18:26   #3 (permalink)
Registered User
 
KLAMATH's Avatar
 
Join Date: Oct 2000
Location: Bucuresti
Ajax poster child loading .
Incarci doar rooturile treeului si generezi pagina pe server. Apoi pe client cind se da click pe un nod faci un request AJAX , iei datele si le adaugi in tree sub nodul curent.
__________________
put a stake thru my heart and drag me into sunlight
 
KLAMATH is offline    Reply With Quote
Old 17-04-2008, 10:59   #4 (permalink)
deep fried
 
Join Date: Sep 2006
Quote:
Originally Posted by KLAMATH View Post
Ajax poster child loading .
Incarci doar rooturile treeului si generezi pagina pe server. Apoi pe client cind se da click pe un nod faci un request AJAX , iei datele si le adaugi in tree sub nodul curent.
Daca are "root-uri" nu mai e tree, e forest . In rest da, what you said
 
SteakHunter is offline    Reply With Quote
Old 17-04-2008, 11:38   #5 (permalink)
75% apa
 
Doctor Bonez's Avatar
 
Join Date: Feb 1999
Multumesc de raspunsuri. Din pacate (fericire?), la o cercetare mai atenta a codului a reiesit ca motivul pentru care dura atat de mult loading-ul era modul cretin in care acesta se facea (i.e. "luat totul la gramada si lookup manual" in loc de filtre in query --> exponential time).

De la ~13 secunde am adus intreaga operatiunea la 10-100 ms., ceea ce elimina necesitatea unui mecanism de caching in background...
__________________
Nashpa...

"In the beginning the Universe was created. This has made a lot of people very angry
and been widely regarded as a bad move." (Douglas Adams)

 
Doctor Bonez is offline    Reply With Quote
Advertisment
Reply

  Computer Games Forum > Tech > The Workshop > Limbaje de programare

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +2. The time now is 06:39.


Advertisement System V2.5 By   Branden
This site is copyrighted ©1997 - 2008, Computer Games Online SRL