This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FileDescriptor suggestion [Was: FYI: Patch: java nio file locking]


Hi Per,

>There wouldn't be any for FileDescriptor, since it has no native
>methods....

I understand that. I was looking for the analagous PlatformChannelSomething
like you had before.

>All the stuff that used to be there would instead be in gnu.java.no.channels.natFileChannel*.cc.

But here we're talking FileChannel again. Don't I want a PlatformSomething that
can encapsulate any platform file descriptor, including those for sockets, etc.?

>> Why int? For me, an int is a quantity. That's not to say that someone's not
>> allowed to typedef to an int as an implementation detail, but exposing a raw
>> int datatype in all its glory for something other than a quantity seems a breach
>> of encapsulation to me. C has had "typedef" from day one, so in my mind,
>> there was no excuse for this.
>
>It's still an int or a pointer.
>
>A Posix file descriptor is an "unforgeable pointer" into kernel space.
>I.e. it's an index into a kernel table.

These are implementation details, though, that I don't want to trickle into my code.
(The typedef is a step in the right direction, but it's less-than-perfect because the
compiler doesn't enforce type distinctness for typedefs which map to the same
thing. I'd still be happier with this though, than seeing a plain int.)

>> Probably, but one array where the index is the int? Or two arrays where one contains
>> the int and the other the handle? Both solutions require the unnecessary global
>> synchronization that this approach entails.
>
>You only need synchronization if you have threads.

I'm assuming that threads are a given.

> > (Or are they doing this some other way,
>> like casting the pointer to an int, but I don't think so because there's a special function
>> for getting the OS handle for such an int file descriptor, but maybe they did this to
>> encapsulate the typecast - aaaaaargh!).
>
>That's not possible, since Posix compatibility requires that 0/1/2
>be stdin/stdout/stderr.  Plus you have 'dup', so just casting handles
>doesn't work.

Good point. (I warned you that I was/am sleepy.... :))

-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]