Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clean-libraries
Commits
f593ff37
Commit
f593ff37
authored
Feb 04, 2000
by
Peter Achten
Browse files
(PA): textual changes because of writing object I/O tutorial
parent
e9056d70
Changes
10
Hide whitespace changes
Inline
Side-by-side
libraries/ObjectIO/ObjectIO/StdPrint.dcl
View file @
f593ff37
...
...
@@ -4,10 +4,6 @@ definition module StdPrint
// Clean Standard Object I/O library, version 1.2
//
// StdPrint specifies general printing functions.
// Related functions and modules:
// - getResolution (StdPicture)
// - resizeBitmap (StdBitmap)
// - StdPrintText to print text.
// ********************************************************************************
...
...
@@ -21,7 +17,7 @@ from iostate import IOSt, PSt
from
StdFile
import
FileEnv
,
Files
::
PageDimensions
=
{
page
::
!
Size
//
s
ize of the drawable area of the page
=
{
page
::
!
Size
//
S
ize of the drawable area of the page
,
margins
::
!
Rectangle
// This field contains information about the
// size of the margins on a sheet in pixels.
// Drawing can't occur within these margins.
...
...
@@ -29,39 +25,42 @@ from StdFile import FileEnv, Files
// page size. Its values are:
// corner1.x<=0 && corner1.y<=0 &&
// corner2.x>=page.w && corner2.y>=page.h
,
resolution
::
!(!
Int
,!
Int
)
//
h
orizontal and vertical printer
,
resolution
::
!(!
Int
,!
Int
)
//
H
orizontal and vertical printer
// resolution in dpi
}
defaultPrintSetup
::
!*
env
->
(!
PrintSetup
,
!*
env
)
defaultPrintSetup
::
!*
env
->
(!
PrintSetup
,!*
env
)
|
FileEnv
env
// returns a default print setup
/* defaultPrintSetup returns a default print setup.
*/
printSetupDialog
::
!
PrintSetup
!*
printEnv
->
(!
PrintSetup
,
!*
printEnv
)
|
PrintEnvironments
printEnv
// lets the user choose a print setup via the print setup dialog
getPageDimensions
::
!
PrintSetup
!
Bool
->
PageDimensions
instance
==
PageDimensions
printSetupDialog
::
!
PrintSetup
!*
env
->
(!
PrintSetup
,!*
env
)
|
PrintEnvironments
env
/* printSetupDialog lets the user choose a print setup via the print setup dialog.
*/
fwritePrintSetup
::
!
PrintSetup
!
*
File
->
*
File
// writes PrintSetup to file (text or data)
getPageDimensions
::
!
PrintSetup
!
Bool
->
PageDimensions
instance
==
PageDimensions
freadPrintSetup
::
!*
File
!*
env
->
(!
Bool
,
!
PrintSetup
,
!*
File
,
!*
env
)
|
FileEnv
env
// reads PrintSetup from File (text or data). If resulting Boolean is True:success,
// otherwise the default PrintSetup is returned
fwritePrintSetup
::
!
PrintSetup
!*
File
->
*
File
/* fwritePrintSetup writes PrintSetup to file (text or data).
*/
freadPrintSetup
::
!*
File
!*
env
->
(!
Bool
,!
PrintSetup
,!*
File
,!*
env
)
|
FileEnv
env
/* freadPrintSetup reads PrintSetup from File (text or data).
If the resulting Boolean is True: success, otherwise the default PrintSetup is
returned.
*/
print
::
!
Bool
!
Bool
.(
PrintInfo
!*
Picture
->
([
IdFun
*
Picture
],!*
Picture
))
!
PrintSetup
!*
printEnv
->
(!
PrintSetup
,!*
printEnv
)
|
PrintEnvironments
printEnv
!
PrintSetup
!*
env
->
(!
PrintSetup
,!*
env
)
|
PrintEnvironments
env
/* print doDialog emulateScreen pages printSetup env
sends output to the printer and returns the used print setup, which can differ
from the input print setup
from the input print setup
.
doDialog:
if True a dialog will pop up that lets the user choose all printing options,
otherwise printing will happen in the default way.
...
...
@@ -80,10 +79,9 @@ print :: !Bool !Bool
printUpdateFunction
::
!
Bool
(
UpdateState
->
*
Picture
->
*
Picture
)
[
Rectangle
]
!
PrintSetup
!*
printEnv
->
(!
PrintSetup
,!*
printEnv
)
|
PrintEnvironments
printEnv
!
PrintSetup
!*
env
->
(!
PrintSetup
,!*
env
)
|
PrintEnvironments
env
/* printUpdateFunction doDialog update area printSetup env
sends the content of the update function of a given area to the printer:
doDialog:
...
...
@@ -98,14 +96,14 @@ printUpdateFunction
identical to print.
*/
printPagePerPage
::
!
Bool
!
Bool
.
x
.(.
x
->
.(
PrintInfo
->
.(*
Picture
->
((.
Bool
,
Point2
),(.
state
,*
Picture
)))))
((.
state
,
*
Picture
)
->
((.
Bool
,
Point2
),(.
state
,*
Picture
)))
!
PrintSetup
!*
printEnv
->
(
Alternative
.
x
.
state
,!*
printE
nv
)
|
PrintEnvironments
printE
nv
printPagePerPage
::
!
Bool
!
Bool
.
x
.(.
x
->
.(
PrintInfo
->
.(
*
Picture
->
((.
Bool
,
Point2
),(.
state
,*
Picture
)))
))
((.
state
,*
Picture
)
->
((.
Bool
,
Point2
),(.
state
,*
Picture
)))
!
PrintSetup
!*
e
nv
->
(
Alternative
.
x
.
state
,!*
e
nv
)
|
PrintEnvironments
env
/* printPagePerPage doDialog emulateScreen x prepare pages printSetup env
sends output to the printer.
This function can be used more efficiently than print. The major difference is
...
...
@@ -113,7 +111,6 @@ printPagePerPage :: !Bool !Bool
producing function. Each page transition function generates one page for the
printer. An additional feature of printPagePerPage is that it is possible to
set the origin of the printer Pictures.
doDialog:
identical to print.
emulateScreen:
...
...
@@ -141,5 +138,5 @@ printPagePerPage :: !Bool !Bool
*/
instance
PrintEnvironments
World
/
/ o
ther instances are the Files subworld and PSt
(see osprint.dcl)
/
* O
ther instances are the Files subworld and PSt
.
*/
libraries/ObjectIO/ObjectIO/StdPrintText.dcl
View file @
f593ff37
...
...
@@ -10,38 +10,37 @@ from StdPictureDef import FontDef, FontName, FontStyle, FontSize
import
StdPrint
from
StdString
import
String
::
WrapMode
:==
Int
::
WrapMode
:==
Int
NoWrap
:==
0
LeftJustify
:==
1
RightJustify
:==
2
class
CharStreams
cs
where
class
CharStreams
cs
where
getChar
::
!*
cs
->
(!
Bool
,!
Char
,!*
cs
)
//
returns the
charstreams
next character
, and whether this operation was
//
successful
//
getChar
returns the next character
of the stream. The Boolean
//
result indicates whether this operation was
successful
.
savePos
::
!*
cs
->
*
cs
//
saves actual position of charstream to
be
enable the
restorePos function
//
to
restore
it then
.
//
savePos
saves actual position of charstream to enable the
// restore
Pos function to restore it
.
restorePos
::
!*
cs
->
*
cs
eos
::
!*
cs
->
(!
Bool
,!*
cs
)
//
end of stream
//
eos checks for
end of stream
.
instance
CharStreams
FileCharStream
::
*
FileCharStream
::
*
FileCharStream
fileToCharStream
::
!*
File
->
*
FileCharStream
charStreamToFile
::
!*
FileCharStream
->
*
File
printText1
::
!
Bool
!
WrapMode
!
FontDef
!
Int
!*
charStream
!
PrintSetup
!*
printEnv
->
(!(!*
charStream
,!
PrintSetup
),!*
printEnv
)
|
CharStreams
charStream
&
PrintEnvironments
printEnv
/* printText1 doDialog wrapMode font spacesPerTab charStream printSetup env
printText1
::
!
Bool
!
WrapMode
!
FontDef
!
Int
!*
charStream
!
PrintSetup
!*
env
->
(!(!*
charStream
,!
PrintSetup
),!*
env
)
|
CharStreams
charStream
&
PrintEnvironments
env
/* printText1 doDialog wrapMode font spacesPerTab
charStream printSetup env
prints a CharStream:
doDialog:
identical to print (StdPrint)
...
...
@@ -58,14 +57,15 @@ printText1 :: !Bool !WrapMode !FontDef !Int !*charStream !PrintSetup !*printEnv
identical to print (StdPrint)
*/
printText2
::
!
String
!
String
!
Bool
!
WrapMode
!
FontDef
!
Int
!*
charStream
!
PrintSetup
!*
env
->
(!(!*
charStream
,!
PrintSetup
),!*
env
)
|
CharStreams
charStream
&
PrintEnvironments
env
printText2
::
!
String
!
String
!
Bool
!
WrapMode
!
FontDef
!
Int
!*
charStream
!
PrintSetup
!*
printEnv
->
(!(!*
charStream
,!
PrintSetup
),!*
printEnv
)
|
CharStreams
charStream
&
PrintEnvironments
printEnv
/* printText2 titleStr pageStr doDialog wrapMode fontParams spacesPerTab charStream
printSetup env
/* printText2 titleStr pageStr
doDialog wrapMode fontParams spacesPerTab
charStream printSetup env
prints a charStream with a header on each page.
titleStr:
this String will be printed on each page at the left corner of the header
...
...
@@ -75,17 +75,16 @@ printText2 :: !String !String !Bool !WrapMode !FontDef !Int !*charStream !PrintS
The other parameters are identical to printText1.
*/
printText3
::!
Bool
!
WrapMode
!
FontDef
!
Int
.(
PrintInfo
*
Picture
->
(
state
,
(
Int
,
Int
),
*
Picture
))
(
state
Int
*
Picture
->
*
Picture
)
!*
charStream
!
PrintSetup
!*
printEnv
->
(!(!*
charStream
,!
PrintSetup
),!*
printEnv
)
|
CharStreams
charStream
&
PrintEnvironments
printEnv
/* printText3 doDialog wrapMode font spacesPerTab textRange eachPageDraw charStream
printSetup env
printText3
::
!
Bool
!
WrapMode
!
FontDef
!
Int
.(
PrintInfo
*
Picture
->
(
state
,
(
Int
,
Int
),
*
Picture
))
(
state
Int
*
Picture
->
*
Picture
)
!*
charStream
!
PrintSetup
!*
env
->
(!(!*
charStream
,!
PrintSetup
),!*
env
)
|
CharStreams
charStream
&
PrintEnvironments
env
/* printText3 doDialog wrapMode font spacesPerTab
textRange
eachPageDraw
charStream printSetup env
prints a charStream with a header and trailer on each page.
textRange:
this function takes a PrintInfo record and the printer Picture on which the
...
...
@@ -99,13 +98,12 @@ printText3 ::!Bool !WrapMode !FontDef !Int
printed for each page.
eachPageDraw:
this function draws the header and/or trailer for the current page. Its
arguments are the data produced by textRange, the actual page number, and
an
initial printer Picture. This function is applied by printText3 before
each new
page receives its text.
arguments are the data produced by textRange, the actual page number, and
an
initial printer Picture. This function is applied by printText3 before
each new
page receives its text.
The other parameters are identical to printText1.
*/
/* If a file is openend with FReadData, then all possible newline conventions
(unix,mac,dos) will be recognized. All these printing functions will replace
nonprintable characters of the font with ASCII spaces. Exceptions are: newline,
...
...
libraries/ObjectIO/ObjectIO/StdProcess.dcl
View file @
f593ff37
...
...
@@ -18,7 +18,6 @@ from iostate import PSt, IOSt
class
Processes
pdef
where
startProcesses
::
!
pdef
!*
World
->
*
World
openProcesses
::
!
pdef
!(
PSt
.
l
)
->
PSt
.
l
/* (start/open)Processes creates an interactive process topology specified by
the pdef argument.
All interactive processes can communicate with each other by means of the
...
...
@@ -32,9 +31,6 @@ class Processes pdef where
instance
Processes
[
pdef
]
|
Processes
pdef
instance
Processes
Process
// Convenience process creation functions:
startIO
::
!
DocumentInterface
!.
l
!(
ProcessInit
(
PSt
.
l
))
![
ProcessAttribute
(
PSt
.
l
)]
!*
World
->
*
World
...
...
@@ -44,7 +40,7 @@ startIO :: !DocumentInterface !.l !(ProcessInit (PSt .l))
// Process access operations:
closeProcess
::
!(
PSt
.
l
)
->
PSt
.
l
closeProcess
::
!(
PSt
.
l
)
->
PSt
.
l
/* closeProcess removes all abstract devices that are held in the interactive
process.
If the interactive process has processes that share its GUI then these will also
...
...
@@ -53,8 +49,8 @@ closeProcess :: !(PSt .l) -> PSt .l
*/
hideProcess
::
!(
PSt
.
l
)
->
PSt
.
l
showProcess
::
!(
PSt
.
l
)
->
PSt
.
l
hideProcess
::
!(
PSt
.
l
)
->
PSt
.
l
showProcess
::
!(
PSt
.
l
)
->
PSt
.
l
/* If the interactive process is active, hideProcess hides the interactive process,
and showProcess makes it visible. Note that hiding an interactive process does
NOT disable the process but simply makes it invisible.
...
...
@@ -64,7 +60,6 @@ getProcessWindowPos :: !(IOSt .l) -> (!Point2,!IOSt .l)
/* getProcessWindowPos returns the current position of the ProcessWindow.
*/
getProcessWindowSize
::
!(
IOSt
.
l
)
->
(!
Size
,!
IOSt
.
l
)
/* getProcessWindowSize returns the current size of the ProcessWindow.
*/
libraries/ObjectIO/ObjectIO/StdReceiver.dcl
View file @
f593ff37
definition
module
StdReceiver
// ********************************************************************************
// Clean Standard Object I/O library, version 1.2
//
// StdReceiver specifies all receiver operations.
// ********************************************************************************
import
StdReceiverDef
,
StdMaybe
from
iostate
import
PSt
,
IOSt
from
id
import
RId
,
R2Id
,
RIdtoId
,
R2IdtoId
,
==
// Operations on the ReceiverDevice.
// Open uni- and bi-directional receivers:
class
Receivers
rdef
where
...
...
@@ -31,18 +27,16 @@ instance Receivers (Receiver msg)
instance
Receivers
(
Receiver2
msg
resp
)
closeReceiver
::
!
Id
!(
IOSt
.
l
)
->
IOSt
.
l
closeReceiver
::
!
Id
!(
IOSt
.
l
)
->
IOSt
.
l
/* closeReceiver closes the indicated uni- or bi-directional receiver.
Invalid Ids have no effect.
*/
getReceivers
::
!(
IOSt
.
l
)
->
(![(
Id
,
ReceiverType
)],
!
IOSt
.
l
)
getReceivers
::
!(
IOSt
.
l
)
->
(![(
Id
,
ReceiverType
)],
!
IOSt
.
l
)
/* getReceivers returns the Ids and ReceiverTypes of all currently open uni- or
bi-directional receivers of this interactive process.
*/
enableReceivers
::
![
Id
]
!(
IOSt
.
l
)
->
IOSt
.
l
disableReceivers
::
![
Id
]
!(
IOSt
.
l
)
->
IOSt
.
l
getReceiverSelectState
::
!
Id
!(
IOSt
.
l
)
->
(!
Maybe
SelectState
,!
IOSt
.
l
)
...
...
@@ -56,7 +50,6 @@ getReceiverSelectState :: ! Id !(IOSt .l) -> (!Maybe SelectState,!IOSt .l)
receiver does not exist, Nothing is returned.
*/
// Inter-process communication:
// Message passing status report:
...
...
libraries/ObjectIO/ObjectIO/StdReceiverAttribute.dcl
View file @
f593ff37
...
...
@@ -32,7 +32,7 @@ isValidReceiver2Attribute :: !(ReceiverAttribute .st) -> Bool
*/
isReceiverInit
::
!(
ReceiverAttribute
.
st
)
->
Bool
isReceiverSelectState
::
!(
ReceiverAttribute
.
st
)
->
Bool
isReceiverConnectedReceivers
::
!(
ReceiverAttribute
.
st
)
->
Bool
// MW11++
isReceiverConnectedReceivers
::
!(
ReceiverAttribute
.
st
)
->
Bool
/* The following functions return the attribute value if appropriate.
THESE ARE PARTIAL FUNCTIONS! They are only defined on the corresponding
...
...
@@ -40,4 +40,4 @@ isReceiverConnectedReceivers:: !(ReceiverAttribute .st) -> Bool // MW11++
*/
getReceiverInitFun
::
!(
ReceiverAttribute
.
st
)
->
IdFun
.
st
getReceiverSelectStateAtt
::
!(
ReceiverAttribute
.
st
)
->
SelectState
getReceiverConnectedReceivers
::
!(
ReceiverAttribute
.
st
)
->
[
Id
]
// MW11++
getReceiverConnectedReceivers
::
!(
ReceiverAttribute
.
st
)
->
[
Id
]
libraries/ObjectIO/ObjectIO/StdTimerElementClass.dcl
View file @
f593ff37
...
...
@@ -19,9 +19,9 @@ class TimerElements t where
getTimerElementType
::
(
t
.
ls
.
pst
)
->
TimerElementType
instance
TimerElements
(
NewLS
t
)
|
TimerElements
t
// getTimerElementType==""
instance
TimerElements
(
AddLS
t
)
|
TimerElements
t
// getTimerElementType==""
instance
TimerElements
(
ListLS
t
)
|
TimerElements
t
// getTimerElementType==""
instance
TimerElements
NilLS
// getTimerElementType==""
instance
TimerElements
(
NewLS
t
)
|
TimerElements
t
instance
TimerElements
(
AddLS
t
)
|
TimerElements
t
instance
TimerElements
(
ListLS
t
)
|
TimerElements
t
instance
TimerElements
NilLS
instance
TimerElements
((:+:)
t1
t2
)
|
TimerElements
t1
&
TimerElements
t2
// getTimerElementType==""
&
TimerElements
t2
libraries/ObjectIO/Tcp/StdChannels.dcl
View file @
f593ff37
...
...
@@ -12,95 +12,105 @@ from tcp import ChannelEnv
instance
ChannelEnv
World
///////////////////////////////// receive channels /////////////////////////////////
class
Receive
ch
where
receive_MT
::
!(
Maybe
!
Timeout
)
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
!
Maybe
!.
a
,!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
receiveUpTo
::
!
Int
!*(*
ch
.
a
)
!*
env
->
(![.
a
],
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
available
::
!*(*
ch
.
a
)
!*
env
->
(!
Bool
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
eom
::
!*(*
ch
.
a
)
!*
env
->
(!
Bool
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
// ********************************************************************************
// receive channels
// ********************************************************************************
class
Receive
ch
where
receive_MT
::
!(
Maybe
!
Timeout
)
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
!
Maybe
!.
a
,!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
receiveUpTo
::
!
Int
!*(*
ch
.
a
)
!*
env
->
(![.
a
],
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
available
::
!*(*
ch
.
a
)
!*
env
->
(!
Bool
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
eom
::
!*(*
ch
.
a
)
!*
env
->
(!
Bool
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
/* receive_MT
tries to receive on a channel. This function will block
,
until data can be
received, eom becomes true or the timeout expires.
tries to receive on a channel. This function will block until data can be
received, eom becomes true
,
or the timeout expires.
receiveUpTo max ch env
receives messages on a channel until available becomes False or max
messages have been received.
available
polls on a channel
,
whether some data is ready to be received. If the
polls on a channel whether some data is ready to be received. If the
returned Boolean is True, then a following receive_MT will not block and
return TR_Success.
eom ("end of messages")
polls on a channel
,
whether data can't be received anymore.
polls on a channel whether data can't be received anymore.
*/
class
closeRChannel
ch
::
!*(*
ch
.
a
)
!*
env
->
!*
env
|
ChannelEnv
env
// closes the channel
// Closes the channel
//////////////////////////////// send channels /////////////////////////////////////
// ********************************************************************************
// send channels
// ********************************************************************************
class
Send
ch
where
send_MT
::
!(
Maybe
!
Timeout
)
!.
a
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
!
Int
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
nsend_MT
::
!(
Maybe
!
Timeout
)
![.
a
]
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
!
Int
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
flushBuffer_MT
::
!(
Maybe
!
Timeout
)
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
!
Int
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
closeChannel_MT
::
!(
Maybe
!
Timeout
)
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
!
Int
,
!*
env
)
|
ChannelEnv
env
abortConnection
::
!*(*
ch
.
a
)
!*
env
->
!*
env
|
ChannelEnv
env
disconnected
::
!*(*
ch
.
a
)
!*
env
->
(!
Bool
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
bufferSize
::
!*(*
ch
.
a
)
->
(!
Int
,
!*(*
ch
.
a
))
class
Send
ch
where
send_MT
::
!(
Maybe
!
Timeout
)
!.
a
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
!
Int
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
nsend_MT
::
!(
Maybe
!
Timeout
)
![.
a
]
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
!
Int
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
flushBuffer_MT
::
!(
Maybe
!
Timeout
)
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
!
Int
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
closeChannel_MT
::
!(
Maybe
!
Timeout
)
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
!
Int
,
!*
env
)
|
ChannelEnv
env
abortConnection
::
!*(*
ch
.
a
)
!*
env
->
!*
env
|
ChannelEnv
env
disconnected
::
!*(*
ch
.
a
)
!*
env
->
(!
Bool
,
!*(*
ch
.
a
),
!*
env
)
|
ChannelEnv
env
bufferSize
::
!*(*
ch
.
a
)
->
(!
Int
,
!*(*
ch
.
a
))
/* send_MT mbTimeout a ch env
adds the data a to the channels internal buffer and tries to send this buffer
adds the data a to the channels internal buffer and tries to send this
buffer.
nsend_MT mbTimeout l ch env
adds the data l to the channels internal buffer and tries to send this buffer
adds the data l to the channels internal buffer and tries to send this
buffer.
flushBuffer_MT
tries to send the channels internal buffer
tries to send the channels internal buffer
.
closeSChannel_MT
first tries to send the channels internal buffer and then closes the channel
first tries to send the channels internal buffer and then closes the
channel.
abortConnection
will cause an abortive disconnect (sent data can be lost)
will cause an abortive disconnect (sent data can be lost)
.
disconnected
polls on a channel, whether data can't be sent anymore. If the returned
Boolean is True, then a following send_MT will not block and return
TR_NoSuccess
bufferSize returns the size of the channels internal buffer in bytes
TR_NoSuccess.
bufferSize
returns the size of the channels internal buffer in bytes.
The integer value that is returned by send_MT, nsend_MT, flushBuffer_MT
&
The integer value that is returned by send_MT, nsend_MT, flushBuffer_MT
, and
closeSChannel_MT is the number of sent bytes.
*/
////////////////////////////////// miscellaneous ///////////////////////////////////
class
MaxSize
ch
where
// ********************************************************************************
// miscellaneous
// ********************************************************************************
class
MaxSize
ch
where
setMaxSize
::
!
Int
!*(*
ch
.
a
)
->
*(*
ch
.
a
)
getMaxSize
::
!*(*
ch
.
a
)
->
(!
Int
,
!*(*
ch
.
a
))
clearMaxSize
::
!*(*
ch
.
a
)
->
*(*
ch
.
a
)
//
to s
et,get or clear the maximum size of the data that can be received
//
S
et,
get
,
or clear the maximum size of the data that can be received
::
DuplexChannel
sChannel
rChannel
a
=
{
sChannel
::
sChannel
a
,
rChannel
::
rChannel
a
::
DuplexChannel
sChannel
rChannel
a
=
{
sChannel
::
sChannel
a
,
rChannel
::
rChannel
a
}
::
TimeoutReport
...
...
@@ -108,24 +118,26 @@ class MaxSize ch
|
TR_Success
|
TR_NoSuccess
::
Timeout
:==
Int
// timeout in ticks
::
Timeout
:==
Int
// timeout in ticks
::
ReceiveMsg
m
=
Received
m
|
EOM
// receiving "EOM" will automatically close the receiver
::
SendEvent
=
Sendable
|
Disconnected
// receiving "Disconnected" will automatically close the
// receiver
::
ReceiveMsg
m
=
Received
m
|
EOM
// Receiving "EOM" automatically closes the receiver
::
SendEvent
=
Sendable
|
Disconnected
// Receiving "Disconnected" automatically closes the receiver
instance
==
TimeoutReport
instance
toString
TimeoutReport
instance
==
TimeoutReport
instance
toString
TimeoutReport
//////////////////////////////// derived functions /////////////////////////////////
nreceive_MT
::
!(
Maybe
!
Timeout
)
!
Int
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
![.
a
],
!*(*
ch
.
a
),
!*
env
)
|
Receive
ch
&
ChannelEnv
env
// ********************************************************************************
// derived functions
// ********************************************************************************
nreceive_MT
::
!(
Maybe
!
Timeout
)
!
Int
!*(*
ch
.
a
)
!*
env
->
(!
TimeoutReport
,
![.
a
],!*(*
ch
.
a
),!*
env
)
|
Receive
ch
&
ChannelEnv
env
/* nreceive_MT mbTimeout n ch env
tries to call receive_MT n times. If the result is (tReport, l, ch2, env2),
then the following holds:
...
...
@@ -133,10 +145,10 @@ nreceive_MT :: !(Maybe !Timeout) !Int !*(*ch .a) !*env
tReport==TR_NoSuccess => length l<n
*/