indexing
	description: "Class describing a condition variable."
	status: "See notice at end of class."
	date: "$Date$"
	revision: "$Revision$"

class interface
	CONDITION_VARIABLE

create 

	make
			-- Create and initialize condition variable.

feature -- Initialization

	make
			-- Create and initialize condition variable.
	
feature -- Access

	C_memory: INTEGER is 2
			-- Code for the C memory managed
			-- by the garbage collector
			-- (from MEM_CONST)

	Eiffel_memory: INTEGER is 1
			-- Code for the Eiffel memory managed
			-- by the garbage collector
			-- (from MEM_CONST)

	Full_collector: INTEGER is 0
			-- Statistics for full collections
			-- (from MEM_CONST)

	has_owner: BOOLEAN
			-- Is object already associated with a thread?
			-- (from OBJECT_OWNER)

	Incremental_collector: INTEGER is 1
			-- Statistics for incremental collections
			-- (from MEM_CONST)

	is_set: BOOLEAN
			-- Is cond_pointer initialized?

	record_owner
			-- Record calling thread's id.
			-- (from OBJECT_OWNER)
		require -- from OBJECT_OWNER
			not_recorded_yet: not has_owner

	thread_is_owner: BOOLEAN
			-- Is calling thread creator of the object?
			-- (from OBJECT_OWNER)

	Total_memory: INTEGER is 0
			-- Code for all the memory managed
			-- by the garbage collector
			-- (from MEM_CONST)
	
feature -- Measurement

	gc_statistics (collector_type: INTEGER): GC_INFO
			-- Garbage collection information for collector_type.
			-- (from MEMORY)
		require -- from MEMORY
			type_ok: collector_type = full_collector or collector_type = incremental_collector

	memory_statistics (memory_type: INTEGER): MEM_INFO
			-- Memory usage information for memory_type
			-- (from MEMORY)
		require -- from MEMORY
			type_ok: memory_type = total_memory or memory_type = eiffel_memory or memory_type = c_memory
	
feature -- Status report

	chunk_size: INTEGER
			-- Minimal size of a memory chunk. The run-time always
			-- allocates a multiple of this size.
			-- If the environment variable EIF_MEMORY_CHUNK
			-- is defined, it is set to the closest reasonable
			-- value from it.
			-- (from MEMORY)

	coalesce_period: INTEGER
			-- Period of full coalesce (in number of collections)
			-- If the environment variable EIF_FULL_COALESCE_PERIOD
			-- is defined, it is set to the closest reasonable
			-- value from it.
			-- If null, no full coalescing is launched.
			-- (from MEMORY)

	collecting: BOOLEAN
			-- Is garbage collection enabled?
			-- (from MEMORY)

	collection_period: INTEGER
			-- Period of full collection.
			-- If the environment variable EIF_FULL_COLLECTION_PERIOD
			-- is defined, it is set to the closest reasonable
			-- value from it.
			-- If null, no full collection is launched.
			-- (from MEMORY)

	generation_object_limit: INTEGER
			-- Maximum size of object in generational scavenge zone.
			-- If the environment variable EIF_GS_LIMIT
			-- is defined, it is set to the closest reasonable
			-- value from it.
			-- (from MEMORY)

	is_in_final_collect: BOOLEAN
			-- Is GC currently performing final collection
			-- after execution of current program?
			-- Safe to use in dispose.
			-- (from MEMORY)

	largest_coalesced_block: INTEGER
			-- Size of largest coalesced block since last call to
			-- largest_coalesced; 0 if none.
			-- (from MEMORY)

	max_mem: INTEGER
			-- Maximum amount of bytes the run-time can allocate.
			-- (from MEMORY)

	memory_threshold: INTEGER
			-- Minimum amount of bytes to be allocated before
			-- starting an automatic garbage collection.
			-- (from MEMORY)

	referers (an_object: ANY): ARRAY [ANY]
			-- Objects that refer to an_object.
			-- (from MEMORY)

	scavenge_zone_size: INTEGER
			-- Size of generational scavenge zone.
			-- If the environment variable EIF_MEMORY_SCAVENGE
			-- is defined, it is set to the closest reasonable
			-- value from it.
			-- (from MEMORY)

	tenure: INTEGER
			-- Maximum age of object before being considered
			-- as old (old objects are not scanned during
			-- partial collection).
			-- If the environment variable EIF_TENURE_MAX
			-- is defined, it is set to the closest reasonable
			-- value from it.
			-- (from MEMORY)
	
feature -- Status setting

	allocate_compact
			-- Enter `memory' mode: will try to compact memory
			-- before requesting more from the operating system.
			-- (from MEMORY)

	allocate_fast
			-- Enter `speed' mode: will optimize speed of memory
			-- allocation rather than memory usage.
			-- (from MEMORY)

	allocate_tiny
			-- Enter `tiny' mode: will enter `memory' mode
			-- after having freed as much memory as possible.
			-- (from MEMORY)

	broadcast
			-- Unblock all threads blocked on the current condition variable.
		require
			valid_pointer: is_set

	collection_off
			-- Disable garbage collection.
			-- (from MEMORY)

	collection_on
			-- Enable garbage collection.
			-- (from MEMORY)

	destroy
			-- Destroy condition variable.
		require
			valid_pointer: is_set

	disable_time_accounting
			-- Disable GC time accounting (default).
			-- (from MEMORY)

	enable_time_accounting
			-- Enable GC time accouting, accessible in gc_statistics.
			-- (from MEMORY)

	set_coalesce_period (value: INTEGER)
			-- Set coalesce_period. Every value collection,
			-- the Garbage Collector will coalesce
			-- the whole memory.
			-- (from MEMORY)
		require -- from MEMORY
			positive_value: value >= 0

	set_collection_period (value: INTEGER)
			-- Set collection_period. Every value collection,
			-- the Garbage collector will perform a collection
			-- on the whole memory (full collection), otherwise
			-- a simple partial collection is done.
			-- (from MEMORY)
		require -- from MEMORY
			positive_value: value >= 0

	set_max_mem (value: INTEGER)
			-- Set the maximum amount of memory the run-time can allocate.
			-- (from MEMORY)
		require -- from MEMORY
			positive_value: value > 0

	set_memory_threshold (value: INTEGER)
			-- Set a new memory_threshold in bytes. Whenever the memory
			-- allocated for Eiffel reaches this value, an automatic
			-- collection is performed.
			-- (from MEMORY)
		require -- from MEMORY
			positive_value: value > 0

	signal
			-- Unblock one thread blocked on the current condition variable.
		require
			valid_pointer: is_set

	wait (a_mutex: MUTEX)
			-- Block calling thread on current condition variable.
		require
			valid_pointer: is_set
	
feature -- Removal

	collect
			-- Force a partial collection cycle if garbage
			-- collection is enabled; do nothing otherwise.
			-- (from MEMORY)

	free (object: ANY)
			-- Free object, by-passing garbage collection.
			-- Erratic behavior will result if the object is still
			-- referenced.
			-- (from MEMORY)

	full_coalesce
			-- Coalesce the whole memory: merge adjacent free
			-- blocks to reduce fragmentation. Useful, when
			-- a lot of memory is allocated with garbage collector off.
			-- (from MEMORY)

	full_collect
			-- Force a full collection cycle if garbage
			-- collection is enabled; do nothing otherwise.
			-- (from MEMORY)

	mem_free (addr: POINTER)
			-- Free memory of object at addr.
			-- (Preferred interface is free.)
			-- (from MEMORY)
	
invariant

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class CONDITION_VARIABLE