chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] busy-wait in tcp-connect


From: Kon Lovett
Subject: Re: [Chicken-users] busy-wait in tcp-connect
Date: Tue, 22 May 2007 23:42:39 -0700


On May 22, 2007, at 11:11 PM, felix winkelmann wrote:

On 5/22/07, Dan Muresan <address@hidden> wrote:
>> While we're on the topic, I find Chicken's lightweight-threads and
>> srfi-18 compatible streams incredibly useful. However, it's a pity that >> only unit tcp (and the (process) function) can create such streams.
>
> I assume you mean streams that block the current thread on I/O, yes? > That shouldn't be a problem as long as you have an fd and can make it
> non-blocking.

Yes, streams that block the current thread on I/O. Are you saying that I
can already create such streams from an fd? How?


Kon has recently added ##sys#custom-[input|output]-port to the
posix unix which sound like they are useful (Kon, can you say
something about these?)

Not so recent ;-)

They are used by the '##sys#process' routine, which is the guts of the 'process' routines. Part of my refactoring of process into smaller pieces. The ##sys#custom-[input|output]-port routines are essentially the port creation code of the original 'process' procedure.

Im afraid they are undocumented for a reason:

- No UTF8 support
- No Read-String/Read-Line
- No Windows support

However, they do work (in use by the osprocess egg).

(##sys#custom-input-port LOCATION NAME FILENO
                         [BUFFER-INFO [ON-CLOSE [MORE-PREDICATE]]])

(##sys#custom-output-port LOCATION NAME FILENO
                          [BUFFER-INFO [ON-CLOSE]])

LOCATION        calling procedure/context id
NAME            name for the port (usually the process command pathname)
FILENO          open file descriptor
BUFFER-INFO     either a fixnum size or a string
ON-CLOSE        fileno was closed notification procedure
MORE-PREDICATE boolean procedure indicating whether more input is available, usually not needed but the programmer may know something that
                the C 'read' procedure doesn't

Use (##sys#file-nonblocking! FILENO) before calling ##sys#custom- [input|output]-port if such is desired.

Best Wishes,
Kon


You can also look at the nbstdin egg, which has a "nonblocking- input-port"
procedure.


cheers,
felix


_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]