


## unix-threadkit-os-glue.pkg
## COPYRIGHT (c) 1989-1991 John H. Reppy
# Compiled by:
# src/lib/std/standard.lib# The Glue for the UNIX version of threadkit.
stipulate
package io = threadkit_io_manager; # threadkit_io_manager is from src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit-io-manager.pkg package sl = timeout_mailop; # timeout_mailop is from src/lib/src/lib/thread-kit/src/core-thread-kit/timeout-mailop.pkg package pm = process_deathwatch; # process_deathwatch is from src/lib/src/lib/thread-kit/src/process-deathwatch.pkgherein
# This package is used as a generic argument in
#
# src/lib/src/lib/thread-kit/src/posix/thread-scheduler-control.pkg #
# to generic thread_scheduler_control_g from
#
# src/lib/src/lib/thread-kit/src/glue/thread-scheduler-control-g.pkg #
package threadkit_os_glue
: (weak) Threadkit_Os_Glue # Threadkit_Os_Glue is from src/lib/src/lib/thread-kit/src/posix/threadkit-os-glue.api {
# runtime_signals is from src/lib/std/src/nj/runtime-signals.pkg # runtime_signals_guts is from src/lib/std/src/nj/runtime-signals-guts.pkg fun init ()
=
sl::reset_sleep_queue_to_empty ();
# This function is (only) called twice, from
# src/lib/src/lib/thread-kit/src/glue/threadkit-export-function-g.pkg #
fun poll_os ()
=
{ sl::wake_sleeping_threads_whose_time_has_come ();
io::poll_io ();
pm::poll_processes ();
};
# Function called when there is nothing else to do.
# Returns FALSE if there are no threads blocked
# on OS conditions.
#
# This function is called exactly once,
# by pause_fate() in:
#
# src/lib/src/lib/thread-kit/src/glue/threadkit-export-function-g.pkg #
fun pause ()
=
case (sl::time_until_next_sleeping_thread_wakes ())
THE t
=>
{
# Eventually, we should just go to sleep
# for the specified time: XXX BUGGO FIXME
#
runtime_signals::pause (); # Ultimately calls unix clib pause().
TRUE;
};
NULL
=>
if ( io::any_waiting ()
or pm::any_waiting ()
)
runtime_signals::pause ();
TRUE;
else
FALSE;
fi;
esac;
fun shutdown ()
=
sl::reset_sleep_queue_to_empty ();
};
end;
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2012,
## released under Gnu Public Licence version 3.


