indexing description: "[ This is a test that uses a lot of threads doing a lot of things with the same hierarchy, loggers, and appenders. No deadlocks ore crashes are supposed to happen. ]" library: "elogger" copyright: "Copyright (c) 2006, AXA Rosenberg, and others (see copyright.txt)" author: "Ulrich Weiss, and others" license: "Eiffel Forum License v2 (see forum.txt)" date: "$Date: $" revision: "$Revision: $" archive: "$Archive: $" class ELOG_TEST_CONCURRENCY_ENDLESS inherit ELOG_SEVERITY_CONSTANTS THREAD_CONTROL creation make feature {NONE} -- Initialization make (producers: INTEGER) is -- creation procedure require producers_greater_than_zero: producers > 0 local i, i2: INTEGER sum: INTEGER_64 h: ELOG_HIERARCHY p: ARRAY [ELOG_TEST_PRODUCER] a_producer: ELOG_TEST_PRODUCER a: ELOG_STDOUT_APPENDER logger: ELOG_LOGGER percentage: REAL_64 size, stars: INTEGER att: THREAD_ATTRIBUTES do -- create hierarchy and start a few producer_threads create h.make (Warning_severity) create p.make (1, producers) create a.make ("stdout appender", False) -- if the appender is not blocking and the buffer size is -- limited, some messages will be discarded! a.set_blocking (False) a.set_buffer_size (5) a.set_layout (create {ELOG_DATE_TIME_LAYOUT}) logger := h.logger ("a.b.c") logger.add_appender (a) from i := 1 until i > producers loop io.put_string ("create producer "+i.out+"%N") create att.make att.set_policy ({THREAD_ATTRIBUTES}.default_policy) att.set_detached (True) a_producer := create {ELOG_TEST_PRODUCER}.make (h, i, a) a_producer.launch_with_attributes (att) p.put (a_producer, i) i := i + 1 end io.put_string ("finished creating producers%N") size := 100 io.read_character from i := 1 until i > producers loop p.item (i).suspend i := i + 1 end io.read_character sum := 0 from i := 1 until i > producers loop sum := sum + p.item (i).count i := i + 1 end from i := 1 until i > producers loop percentage := p.item (i).count/sum io.put_string ("producer "+i.out+": "+p.item (i).count.out+"%T") stars := (percentage*size).ceiling from i2 := 0 until i2 > stars loop io.put_character ('*') i2 := i2 + 1 end io.put_new_line i := i + 1 end io.put_new_line end end