NonPositionableExternalStream.st
branchjv
changeset 18800 02724cc719b6
parent 18403 9a3fc7cc7127
parent 18798 0b4860a5c695
child 19103 71257a47eba2
equal deleted inserted replaced
18786:237a87b4fe8f 18800:02724cc719b6
   458 
   458 
   459 atEnd
   459 atEnd
   460     "return true, if position is at end"
   460     "return true, if position is at end"
   461 
   461 
   462     (self == StdInStream) ifTrue:[
   462     (self == StdInStream) ifTrue:[
   463 	OperatingSystem hasConsole ifFalse:[
   463         OperatingSystem hasConsole ifFalse:[
   464 	    ^ true
   464             ^ true
   465 	]
   465         ]
   466     ].
   466     ].
   467 
   467 
   468     "first, wait to avoid blocking on the read.
   468     "first, wait to avoid blocking on the read.
   469      On end of stream or error, readWait will return"
   469      On end of stream or error, readWait will return"
   470 
   470 
   471     self readWait.
   471     self readWaitWithTimeoutMs:nil.
   472     ^ super atEnd.
   472     ^ super atEnd.
   473 !
   473 !
   474 
   474 
   475 collectionSize
   475 collectionSize
   476     "we do not know our size"
   476     "we do not know our size"
   496     ^ self positionError
   496     ^ self positionError
   497 ! !
   497 ! !
   498 
   498 
   499 !NonPositionableExternalStream methodsFor:'reading'!
   499 !NonPositionableExternalStream methodsFor:'reading'!
   500 
   500 
   501 readWait
   501 next
       
   502     "return the next element, if available.
       
   503      If nothing is available, this does never raise a read-beyond end signal.
       
   504      Instead, nil is returned immediately.
       
   505 
       
   506      Redefined, to wait on pipes and sockets"
       
   507 
       
   508     self readWaitWithTimeoutMs:nil.
       
   509     ^ super next
       
   510 !
       
   511 
       
   512 nextLine
       
   513     "Redefined, to wait on pipes and sockets"
       
   514 
       
   515     self readWaitWithTimeoutMs:nil.
       
   516     ^ super nextLine
       
   517 !
       
   518 
       
   519 nextOrNil
       
   520     "like #next, this returns the next element, if available.
       
   521      If nothing is available, this does never raise a read-beyond end signal.
       
   522      Instead, nil is returned immediately.
       
   523 
       
   524      Redefined, to wait on pipes and sockets"
       
   525 
       
   526     self atEnd ifTrue:[^ nil].
       
   527     ^ super nextOrNil
       
   528 !
       
   529 
       
   530 peek
       
   531     "Redefined, to wait on pipes and sockets"
       
   532 
       
   533     self readWaitWithTimeoutMs:nil.
       
   534     ^ super peek
       
   535 !
       
   536 
       
   537 peekOrNil
       
   538     "like #peek, this returns the next element, if available.
       
   539      If nothing is available, this does never raise a read-beyond end signal.
       
   540      Instead, nil is returned immediately.
       
   541 
       
   542      Redefined, to wait on pipes and sockets"
       
   543 
       
   544     self atEnd ifTrue:[^ nil].
       
   545     ^ self peek
       
   546 !
       
   547 
       
   548 readWaitWithTimeoutMs:millisecondsOrNil
   502     "cannot do a readWait (which means possible suspend),
   549     "cannot do a readWait (which means possible suspend),
   503      if the processor is not yet initialized; i.e. if a read is attempted
   550      if the processor is not yet initialized; i.e. if a read is attempted
   504      during early startup.
   551      during early startup.
   505      This may happen, for example, if a MiniDebugger is entered, before
   552      This may happen, for example, if a MiniDebugger is entered, before
   506      process scheduling has been setup.
   553      process scheduling has been setup.
   507      In this case, all I/O operations here will be blocking."
   554      In this case, all I/O operations here will be blocking."
   508 
   555 
   509     Smalltalk isInitialized ifFalse:[ ^ false ].
   556     Smalltalk isInitialized ifFalse:[ ^ false ].
   510     ^ super readWait
   557     ^ super readWaitWithTimeoutMs:millisecondsOrNil
   511 !
       
   512 
       
   513 next
       
   514     "return the next element, if available.
       
   515      If nothing is available, this does never raise a read-beyond end signal.
       
   516      Instead, nil is returned immediately.
       
   517 
       
   518      Redefined, to wait on pipes and sockets"
       
   519 
       
   520     self readWait.
       
   521     ^ super next
       
   522 !
       
   523 
       
   524 nextLine
       
   525     "Redefined, to wait on pipes and sockets"
       
   526 
       
   527     self readWait.
       
   528     ^ super nextLine
       
   529 !
       
   530 
       
   531 nextOrNil
       
   532     "like #next, this returns the next element, if available.
       
   533      If nothing is available, this does never raise a read-beyond end signal.
       
   534      Instead, nil is returned immediately.
       
   535 
       
   536      Redefined, to wait on pipes and sockets"
       
   537 
       
   538     self atEnd ifTrue:[^ nil].
       
   539     ^ super nextOrNil
       
   540 !
       
   541 
       
   542 peek
       
   543     "Redefined, to wait on pipes and sockets"
       
   544 
       
   545     self readWait.
       
   546     ^ super peek
       
   547 !
       
   548 
       
   549 peekOrNil
       
   550     "like #peek, this returns the next element, if available.
       
   551      If nothing is available, this does never raise a read-beyond end signal.
       
   552      Instead, nil is returned immediately.
       
   553 
       
   554      Redefined, to wait on pipes and sockets"
       
   555 
       
   556     self atEnd ifTrue:[^ nil].
       
   557     ^ self peek
       
   558 ! !
   558 ! !
   559 
   559 
   560 !NonPositionableExternalStream methodsFor:'writing'!
   560 !NonPositionableExternalStream methodsFor:'writing'!
   561 
   561 
   562 nextPutAll:aCollection
   562 nextPutAll:aCollection
   605 ! !
   605 ! !
   606 
   606 
   607 !NonPositionableExternalStream class methodsFor:'documentation'!
   607 !NonPositionableExternalStream class methodsFor:'documentation'!
   608 
   608 
   609 version
   609 version
   610     ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.75 2015-05-24 12:51:37 cg Exp $'
   610     ^ '$Header$'
   611 !
   611 !
   612 
   612 
   613 version_CVS
   613 version_CVS
   614     ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.75 2015-05-24 12:51:37 cg Exp $'
   614     ^ '$Header$'
   615 ! !
   615 ! !
   616 
   616