Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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 09: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 23: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 22: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]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (12 views)
2014-07-29 18:09:19

Riven (9 views)
2014-07-29 18:08:52

Dwinin (9 views)
2014-07-29 10:59:34

E.R. Fleming (26 views)
2014-07-29 03:07:13

E.R. Fleming (10 views)
2014-07-29 03:06:25

pw (40 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (27 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!