/*
Copyright (C) 2001-2007, Parrot Foundation.
$Id: threadinterpreter.pmc 48435 2010-08-12 19:37:47Z chromatic $

=head1 NAME

src/pmc/threadinterpreter.pmc - INTERNAL Interpreter for OS level worker thread(pthread).

=head1 DESCRIPTION

ThreadInterpreter extends ParrotInterpreter to provide a interpreter
to be used internally in a OS level worker thread(pthread).
which supports:

=head2 Methods

=over 4

=cut

*/

#include "parrot/embed.h"

/* HEADERIZER HFILE: none */
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */

static void stop_GC(ARGMOD(Interp *parent), ARGMOD(Interp *thread))
        __attribute__nonnull__(1)
        __attribute__nonnull__(2)
        FUNC_MODIFIES(*parent)
        FUNC_MODIFIES(*thread);

#define ASSERT_ARGS_stop_GC __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
       PARROT_ASSERT_ARG(parent) \
    , PARROT_ASSERT_ARG(thread))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
/* HEADERIZER END: static */

#define PMC_interp(x) ((Parrot_ParrotInterpreter_attributes *)PMC_data(x))->interp

/*
 * can't do multi-threaded GC yet
 * XXX a quick hack to pass the few tests
 */

/*

=item C<static void stop_GC(Interp *parent, Interp *thread)>

=cut

*/

static void
stop_GC(ARGMOD(Interp *parent), ARGMOD(Interp *thread))
{
    ASSERT_ARGS(stop_GC)
    Parrot_block_GC_mark(parent);
    Parrot_block_GC_mark(thread);
    Parrot_block_GC_sweep(parent);
    Parrot_block_GC_sweep(thread);
}



pmclass ThreadInterpreter extends ParrotInterpreter no_ro manual_attrs {

/*

=item C<void init()>

Initializes the thread.

=cut

*/

    VTABLE void init() {
        /* protect interpreter creation and list handling */
        LOCK(interpreter_array_mutex);

        SUPER();
        pt_add_to_interpreters(INTERP, PMC_interp(SELF));

        UNLOCK(interpreter_array_mutex);

        /* can't allow GC runs for now */
        stop_GC(INTERP, PMC_interp(SELF));
    }
}

/*

=back

=cut

*/

/*
 * Local variables:
 *   c-file-style: "parrot"
 * End:
 * vim: expandtab shiftwidth=4:
 */
