It's a definitely possibility. I'll probably wind up still creating
some kind of simple wrapper framework so there can be a
pseudo-non-blocking implementation for platforms not supported by Matts
Java NBIO package (since it uses JNI). Then you can easily switch your
implementation over to the Java non-blocking file IO whenever they get
around to adding it in Java 1.6 or 1.7 or 1.8 or whenever.
Rich
Emmanuel Lecharny wrote:
> Yep, you're right. I answer a little bit too fast, thinking that you
> needed something simpler. The point is that FileLocks just give you a
> lock to files shared with an external process, not with other threads in
> the same JVM.
>
> What about http://www.eecs.harvard.edu/~mdw/proj/java-nbio/ ?
>
> On Sat, 2005-04-09 at 12:55 -0700, Richard Wallace wrote:
>
>>The try lock method is for getting an exclusive lock on a file. It has
>>nothing to do with the actual reading or writing of the file, other than
>>disallowing other threads or processes from opening the file and reading
>>or writing it.
>>
>>Rich
>>
>>Emmanuel Lecharny wrote:
>>
>>>Hi,
>>>
>>>can't you use the FileChannel's tryLock() method?
>>>(http://java.sun.com/j2se/1.4.2/docs/api/java/nio/channels/FileChannel.html#tryLock(long,%20long,%20boolean))
>>>
>>>
>>>
>>>On Fri, 2005-04-08 at 22:38 -0700, Richard Wallace wrote:
>>>
>>>
>>>>Java NIO doesn't support non-blocking file IO. Only non-blocking socket
>>>>IO. If you look you'll see that the FileChannel does not extend the
>>>>SelectableChannel and so cannot be set to non-blocking mode or
>>>>registered with a selector.
>>>>
>>>>Ben Walding wrote:
>>>>
>>>>
>>>>>Am I confused, or is Java NIO not what you're looking for?
>>>>>
>>>>>http://java.sun.com/j2se/1.4.2/docs/guide/nio/
>>>>>
>>>>>Mike Spille wrote some wrappers around NIO, but I'm not sure how active
>>>>>they are:
>>>>>
>>>>>http://sourceforge.net/projects/pyrasun/
>>>>>
>>>>>Richard Wallace wrote:
>>>>>
>>>>>
>>>>>
>>>>>>Hey everyone,
>>>>>>
>>>>>>I'm getting to a point with my smtp protocol provider that I need
to
>>>>>>start thinking about file IO. Since there is no support for
>>>>>>non-blocking IO in Java yet I need something that fakes it. I was
>>>>>>wondering if anyone had any experience with any existing components
>>>>>>that do this. If there aren't any really good ones that anyone can
>>>>>>recommend I'll probably wind up writing something on my own.
>>>>>>
>>>>>>I'm kind of thinking it should basically be a component that uses
a
>>>>>>single thread to monitor a queue for IO requests and then uses
>>>>>>something like the IoHandler in MINA to let clients know when
>>>>>>reads/writes have started/stopped/failed.
>>>>>>
>>>>>>Any input on existing components or what would be necessary to maybe
>>>>>>repurpose parts of MINA for this task would be great.
>>>>>>
>>>>>>Thanks,
>>>>>>Rich
>>>>>>
>>>>>
>>>
>
>
|