Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (683)
Games in Android Showcase (196)
games submitted by our members
Games in WIP (750)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Networking & Multiplayer / NIO write taking up all the process resources on: 2006-05-14 07:24:13
How should the writing to a non-blocking nio channel be handled?
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
if (key.isAcceptable()) {
~ codes ~
client.register(selector, SelectionKey.OP_READ |  SelectionKey.OP_WRITE);
}  else if (key.isConnectable()) {
~ codes ~
client.register(selector, SelectionKey.OP_READ |  SelectionKey.OP_WRITE);
} else if (key.isReadable()) {
~ codes ~
} else if (key.isWritable()) {
~ codes ~
<== writes data to the channel here ==>
}

Apperently if I use that the select will keep returning, therefore eating up the resources.
According to this page http://www-128.ibm.com/developerworks/java/library/j-perf03174.html,
Quote
if the socket is registered with the Selector in WRITE mode, then the Selector.select() call will always return immediately, because it has at least one socket which is ready to be written to.

Now my problem, since calling register() function in a thread other than the one that calls select() will cause blocking problem. How would I write data to the channel if I can't register the channel to write state?
2  Java Game APIs & Engines / Java 2D / Re: Drawing outside of the viewable area.. on: 2006-02-07 22:05:19
Hum.. Thanks for the tip but that's not exactly what I want. Because all the stuff in the drawing would have different coordinations and I only want to display a perticular view. Also there are many objects so I don't want to translate all their coordinates first before drawing it.
3  Java Game APIs & Engines / Java 2D / Drawing outside of the viewable area.. on: 2006-02-07 21:29:43
Hi I'm trying to draw something out of viewing area, but somehow things outside of Canvas bound will not be drawed. Is there anyway I can still draw those? I need to copy the image there and be able to move it around... Any ideas?

Ex:
Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
g.setColor(Color.BLACK);
g.fillRect(-800, -600, 800, 600);

--- other drawings

g.copyArea(-800, -600, 800, 600, 800, 600);

Pages: [1]
 
orrenravid (157 views)
2016-07-16 03:57:23

theagentd (225 views)
2016-07-11 14:28:54

Hydroque (308 views)
2016-07-06 05:56:57

Hydroque (460 views)
2016-07-03 08:52:54

GrandCastle (344 views)
2016-07-01 09:13:47

GrandCastle (336 views)
2016-07-01 09:09:45

CopyableCougar4 (390 views)
2016-06-25 16:56:52

Hydroque (372 views)
2016-06-22 02:17:53

SwampChicken (342 views)
2016-06-20 13:22:57

SwampChicken (290 views)
2016-06-20 13:22:49
Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42

FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!