Newsgroups: perl.perl6.internals
From: d...@sidhe.org (Dan Sugalski)
Date: Mon, 24 May 2004 15:20:52 -0400
Local: Mon, May 24 2004 3:20 pm
Subject: First draft, IO & event design
Since events and IO are really linked, and really (kinda, sorta) the
same thing, it seems silly to have two separate documents that spend half their time referring to the other, and duplicating a lot of stuff between them. (I've a hard enough time keeping things straight within a single document, let alone two) The comments on the first draft that still apply have been ++++++++++++++++++++++++++Snip Here++++++++++++++++++ Events and IO Parrot has a unified event and IO system--indeed events are nothing Basic Architecture The event and IO system revolves around streams, requests, and Each stream in the event and IO system has the same structure. There The preprocessing, anchor, and post-processing layers are isolated The system is simple--you make a request to a stream. The request Non-IO things such as signals and OS events (assuming we can get to At the moment each filehandle has a single set of IO layers which Note that any layer along the way may defer the IO request. A Layer and Callback functions Since IO layers and event callbacks are identical, they have the same (Sreturndata, Icommand) = The returndata from a layer is passed into the next layer as its The commands are: * 1 - Event Negative command arguments indicate that the command request has had Request/Event status Requests and events have one of the following statuses: * Unprocessed - The request has been issued but not yet touched Event/Request classes There are two classses of events and IO requests: solicited and A solicited event or request is one that a user program has An unsolicited event, on the other hand, is one that parrot generates There are four big differences between solicited and unsolicited 1) A solicited event goes through a stream's preprocessing 2) A solicted event may be cancelled from user code, as the user code 3) A solicited event may have a callback and user data associated 4) Any exception associated with a solicited event will be thrown Interfacing with System Events It is possible, given the nature of fighting event loops, that parrot Event Source Methods The following methods are required of any event source that pause Stop the event source from emitting events. Any event that would be hold Like pause, except the events are held rather than discarded. cancel Permanently stop the event source. unpause Undo a pause or hold on the event source. If any events are pending Event Ops The opcodes in this section are a combination of event requests and Most of the event request ops have two forms, one of which takes a checkevent Explicitly check to see if there are any events pending in the event queue and, drainqueue Wait forever, draining the event queue as it fills. This op only wait Pevent Wait for the specified event to complete. If the event has already getstat Istatus, Pevent Returns the status of the event, noting whether it has been completed getdata Pdata, Pevent Get the data associated with the event, if there is any. What the data is getuser Puserdata, Pevent Get the user data that was passed into this event. cancel Pevent Cancel the request, if possible. post Pevent Post an event to the event queue for later handling sethandler Ieventclass, Phandlersub Set the default handler for the specified class of events. seteventlevel Ieventlevel Set the current event level. Events of a lower level than this won't IO Ops These are the ops that control IO. Note that the synchronous versions readw mydata, Filehandle, 500 is equivalent to the sequence read tempevent, Filehandle, 500 but is provided for convenience for those languages which are so newhandle Pfilehandle, Panchorsub Create a new filehandle. C<anchorsub> is the subroutine that anchors pushhandler Pfilehandle, Phandlersub, Ireadwritecontrol pophandler Pfilehandle addhandler Pfilehandle, Phandlersub, Ioffset, Ireadwritecontrol removehandler Pfilehandle, Phandlersub, Ioffset, Ireadwritecontrol read Pevent, Pfilehandle, Ihowmuch[, Pcallback, Puserdata] Request a read of data from the filehandle. readw Pdata, Pfilehandle, Ihowmuch Synchronously read C<howmuch> data from the filehandle. write Pevent, Pfilehandle, Pdata[, Pcallback, Puserdata] Write the data to the filehandle. writew Pfilehandle, Pdata Synchronously write the data to the filehandle seek Pevent, Pfilehandle, Iwhere[, Pcallback, Puserdata] Submit a request to seek to the specified position in the file. tell Pevent, Pfilehandle[, Pcallback, Puserdata] Submit a request for the current position in the filehandle. un_read Pfilehandle, Pdata Undo a read request, pushing Pdata back onto the filehandle. (Note -- --------------------------------------"it's like this"------------------- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||