peek and friends

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

peek and friends

stephane ducasse
hi Igor

finally should I integrate
        http://bugs.squeak.org/view.php?id=7446 ?
I was waiting because you said you were confused

Stef

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: peek and friends

Igor Stasenko
On 29 January 2010 23:09, stephane ducasse <[hidden email]> wrote:
> hi Igor
>
> finally should I integrate
>        http://bugs.squeak.org/view.php?id=7446 ?
> I was waiting because you said you were confused
>

Yes, integrate that, since it deals with issue that #peek should
answer the same byte as following #next.

We turned discussion into other issues, not related to this _bug_ (but
related to #peek behavior), concerning what will happen if timeout
appear. Here the last version(s) of both peek and next which taking
care about it:


!SocketStream methodsFor: 'stream in' stamp: 'Igor.Stasenko 1/15/2010 02:02'!
next
        "Return next byte, if inBuffer is empty
        we recieve some more data and try again."

        [self isDataAvailable] whileFalse: [
                self receiveData. self atEnd ifTrue: [ ^ nil ]].
       
        ^inBuffer at: (lastRead := lastRead + 1)
! !

!SocketStream methodsFor: 'stream in' stamp: 'Igor.Stasenko 1/15/2010 01:33'!
peek
        "Return next byte, if inBuffer is empty
        we recieve some more data and try again.
        Do not consume the byte."

        [self isDataAvailable] whileFalse: [
                self receiveData. self atEnd ifTrue: [ ^ nil ]].
       
        ^inBuffer at: lastRead +1! !


As you can see, the only difference between peek and next is that one
advancing the buffer pointer, while other not.

> Stef
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: peek and friends

Stéphane Ducasse
thanks!

On Jan 30, 2010, at 9:23 AM, Igor Stasenko wrote:

> On 29 January 2010 23:09, stephane ducasse <[hidden email]> wrote:
>> hi Igor
>>
>> finally should I integrate
>>        http://bugs.squeak.org/view.php?id=7446 ?
>> I was waiting because you said you were confused
>>
>
> Yes, integrate that, since it deals with issue that #peek should
> answer the same byte as following #next.
>
> We turned discussion into other issues, not related to this _bug_ (but
> related to #peek behavior), concerning what will happen if timeout
> appear. Here the last version(s) of both peek and next which taking
> care about it:
>
>
> !SocketStream methodsFor: 'stream in' stamp: 'Igor.Stasenko 1/15/2010 02:02'!
> next
> "Return next byte, if inBuffer is empty
> we recieve some more data and try again."
>
> [self isDataAvailable] whileFalse: [
> self receiveData. self atEnd ifTrue: [ ^ nil ]].
>
> ^inBuffer at: (lastRead := lastRead + 1)
> ! !
>
> !SocketStream methodsFor: 'stream in' stamp: 'Igor.Stasenko 1/15/2010 01:33'!
> peek
> "Return next byte, if inBuffer is empty
> we recieve some more data and try again.
> Do not consume the byte."
>
> [self isDataAvailable] whileFalse: [
> self receiveData. self atEnd ifTrue: [ ^ nil ]].
>
> ^inBuffer at: lastRead +1! !
>
>
> As you can see, the only difference between peek and next is that one
> advancing the buffer pointer, while other not.
>
>> Stef
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project