


## internal-threadkit-types.pkg
## COPYRIGHT (c) 1989-1991 John H. Reppy
# Compiled by:
# src/lib/std/standard.lib# These are the concrete representations of the various threadkit types.
# These types are abstract (or not even visible) outside this library.
package internal_threadkit_types {
# Threadkit queues --- see
#
# src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit-queue.pkg #
Threadkit_Queue(X)
=
THREADKIT_QUEUE {
front: Ref( List(X) ),
rear: Ref( List(X) )
};
# Thread IDs --- see
#
# src/lib/src/lib/thread-kit/src/core-thread-kit/thread.pkg #
Thread
=
THREAD # Thread ids.
{ thread_id: Int, # A unique ID.
name: String, # Purely for display to humans.
did_mail: Ref( Bool ), # Set this whenever this thread does some concurrency operation.
exception_handler: Ref( Exception -> Void ), # Root-level exception handler hook.
properties: Ref( List( Exception ) ), # Holds thread-local properties.
dead: Condition_Variable # Set when the thread dies.
}
# Transaction IDs are used to mark blocked
# threads in the various waiting queues.
#
# They are "cancelled" when some other
# mailop is selected.
#
also
Transaction_Id
= CANCELLED_TRANSACTION_ID
| TRANSACTION_ID Thread
# Condition variables --- see
# src/lib/src/lib/thread-kit/src/core-thread-kit/mailop.pkg # These are essentially Void-valued oneshot_maildrop instances,
# and are used for various internal synchronization
# conditions, e.g., nack mail_ops, I/O synchronization,
# and thread termination:
#
also
Condition_Variable
=
CONDITION_VARIABLE Ref( Condition_Variable_State )
also
Condition_Variable_State
= CVAR_UNSET List { transaction_id: Ref( Transaction_Id ),
clean_up: Void -> Void,
fate: fate::Fate( Void )
}
| CVAR_SET Int
;
# Mail ops --- see
# src/lib/src/lib/thread-kit/src/core-thread-kit/mailop.pkg #
Mailop_Status(X)
#
= MAILOP_READY
{ priority: Int,
do_it: Void -> X # Reppy calls this field doFn
}
| MAILOP_UNREADY
{ transaction_id: Ref( Transaction_Id ),
clean_up: Void -> Void,
next: Void -> Void
}
->
X
;
Base_Mailop(X)
=
Void -> Mailop_Status(X);
Mailop(X)
= BASE_MAILOPS List( Base_Mailop(X) )
| CHOOSE List( Mailop(X) )
| GUARD Void -> Mailop(X)
| WITH_NACK Mailop(Void) -> Mailop(X)
;
# Useful when debugging threadkit internals:
#
fun thread_to_string (THREAD { thread_id, ... } )
=
cat [ "[",
number_string::pad_left '0' 6 (int::to_string thread_id),
"]"
];
};
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2012,
## released under Gnu Public Licence version 3.


