You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2008/04/07 19:25:27 UTC

DO NOT REPLY [Bug 44769] New: Add ByteBuffer creation method to org.apache. tomcat.jni.Stdlib

https://issues.apache.org/bugzilla/show_bug.cgi?id=44769

           Summary: Add ByteBuffer creation method to
                    org.apache.tomcat.jni.Stdlib
           Product: Tomcat 6
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Native:Integration
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: trustin@gmail.com


Currently, org.apache.tomcat.jni.Stdlib provides only memory allocation,
deallocation and primitive access methods.

It would be much more useful if there's a method that creates a new ByteBuffer
from the memory region allocated by Stdlib.malloc(), like the following example
code:

// Stdlib.asByteBuffer(long mem, int sz)
long addr = Stdlib.malloc(1024);
ByteBuffer buf = Stdlib.asByteBuffer(addr, 1024);

Optionally exposing a method that returns the address of the ByteBuffer will be
very useful:

// Stdlib.address(ByteBuffer buf)
long addr = Stdlib.address(buf);
Stdlib.free(addr);


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 44769] Add ByteBuffer creation method to org.apache.tomcat.jni.Stdlib

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44769


Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Native:Integration          |Library
            Product|Tomcat 6                    |Tomcat Native
   Target Milestone|default                     |---




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 44769] Add ByteBuffer creation method to org.apache. tomcat.jni.Stdlib

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44769


Mladen Turk <mt...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




--- Comment #2 from Mladen Turk <mt...@apache.org>  2008-04-09 00:53:05 PST ---
Commited to the trunk.
See if the API fits the needs.
Think we'll need the minor version bump for that new class


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 44769] Add ByteBuffer creation method to org.apache. tomcat.jni.Stdlib

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44769





--- Comment #4 from Remy Maucherat <re...@apache.org>  2008-04-09 02:45:07 PST ---
It's in a new Buffer class, but I see no real reason for putting this stuff in
a new class.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 44769] Add ByteBuffer creation method to org.apache. tomcat.jni.Stdlib

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44769


Mladen Turk <mt...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




--- Comment #1 from Mladen Turk <mt...@apache.org>  2008-04-07 12:05:02 PST ---
This looks pretty usable.
It's a simple call to NewDirectByteBuffer

Think it can be done in one call, I mean
allocation and creation of ByteBuffer (much faster)

so

ByteBuffer bb = Stdlib.newDirectByteBuffer(size)
...
Stdlib.freeByteBuffer(bb)

Of course other option would be to use single Stdlib.malloc
of higher size and then create ByteBuffers on slices.

So this

long addr = Stdlib.malloc(1024 * 16)

ByteBuffer bba = Stdlib.asByteBuffer(addr, 1024);
ByteBuffer bbb = Stdlib.asByteBuffer(addr + 1024, 1024);

...
Stdlib.free(addr)

has meaning only if you need to have addr of longer
life then ByteBuffer and you wish to have your
memory manager, which can be very useful in case
you need to create/destroy many objects (malloc is time expensive).

In other case the first one will do.
A Stdlib.getByteBufferAddress(bb) will return the memory
that you can use with Stdlib.memread, memset, etc.

Think I'll implement all options


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 44769] Add ByteBuffer creation method to org.apache. tomcat.jni.Stdlib

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44769


Trustin Lee <tr...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED




--- Comment #5 from Trustin Lee <tr...@gmail.com>  2008-04-09 02:59:02 PST ---
Ah, it's here:

http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/java/org/apache/tomcat/jni/Buffer.java?view=markup

Looks very good to me!


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 44769] Add ByteBuffer creation method to org.apache. tomcat.jni.Stdlib

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44769


Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 44769] Add ByteBuffer creation method to org.apache. tomcat.jni.Stdlib

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44769





--- Comment #3 from Trustin Lee <tr...@gmail.com>  2008-04-09 01:14:49 PST ---
I'm looking into here:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/jni/Stdlib.java?view=markup

but couldn't find the change.  Where's the correct location?


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org