[svn:parrot] r39153 - branches/aio_prototype/src/pmc
chromatic
chromatic at wgz.org
Sun May 24 21:58:12 UTC 2009
On Sunday 24 May 2009 07:50:34 whiteknight at svn.parrot.org wrote:
> Log:
> [aio_prototype] Add two skeletal prototype PMCs: a request object, and a
> polling object to track all outstanding requests
> Added: branches/aio_prototype/src/pmc/iopoll.pmc
>
===========================================================================
>=== --- /dev/null 00:00:00 1970 (empty, because file is newly added)
> +++ branches/aio_prototype/src/pmc/iopoll.pmc Sun May 24 14:50:34
> 2009 (r39153) @@ -0,0 +1,174 @@
> +/*
> +Copyright (C) 2008, Parrot Foundation.
That should be 2009.
> +track_stream_events(PARROT_INTERP, PMC * self, PMC * stream)
The star should cuddle the variable name (the point of this in the coding
standard is so that we never accidentally declare a series of pointers, cuddle
the star to the type name, and leave the star off other pointers).
> +static void
> +track_stream_events(PARROT_INTERP, PMC * self, PMC * stream)
> +{
> + Parrot_IOPoll_attributes * attrs = PARROT_IOREQUEST(self);
> + PIOHANDLE fd;
> + if (attrs->poll.num_fds_current == attrs->poll.num_fds_total) {
> + attrs->poll.num_fds_total += 10;
> + attrs->poll.fdlist = (struct epoll_eents
> *)realloc(attrs->poll.fdlist, + sizeof(struct epoll_events) *
> attrs->poll.num_fds_tota); + }
It's better to use the mem_sys_realloc() and related functions and macros
here. If we ever instrument them for tracing, we'll be able to trace this
call.
> +static void
> +poll_io_request(PARROT_INTERP, PMC * self)
> +{
> + PARROT_IOREQUEST(self)->status = IORequestSuccess;
> +}
Is there a status attribute of this PMC? I don't see it:
> +pmclass IOPoll need_ext {
> + ATTR PIOPOLLOBJ poll; /* OS structure that does the polling */
> + ATTR PMC * requests; /* RPA of IORequest objects that are pending
> + VTABLE void init()
> + {
> + Parrot_IOPoll_attributes * attrs =
> mem_allocate_typed(Parrot_IOPoll_attributes); + PMC_data(SELF) =
> attrs;
> + create_new_poll_object(INTERP, SELF);
> + attrs->requests = pmc_new(interp, enum_class_ResizablePMCArray);
> + PObj_custom_destroy_SET(SELF);
There's a custom mark() VTABLE entry here too, so you meant
PObj_custom_mark_destroy_SETALL(SELF).
> + VTABLE void mark()
> + {
> + Parrot_gc_mark_PObj_alive(INTERP, PARROT_IOPOLL(SELF)->requests);
> + }
> +}
-- c
More information about the parrot-dev
mailing list