note description: "horses_run application root class" date: "$Date$" revision: "$Revision$"
class APPLICATION
inherit ARGUMENTS_32
create make
feature {NONE} -- Initialization
make local l_horses: LINKED_LIST[separate HORSE] do io.put_string ("*********** HORSES RUN START **********************") -- All horses in the field create l_horses.make across 1 |..| 5 is l_horse_id loop l_horses.extend (create {HORSE}.make (l_horse_id)) end -- RUN across l_horses is l_horse loop horse_run (l_horse) end io.put_string ("*********** HORSES RUN END **********************") end
horse_run (a_horse: separate HORSE) do a_horse.run end
end
note description: "Summary description for {HORSE}." author: "" date: "$Date$" revision: "$Revision$"
class HORSE
create make
feature {NONE} -- Initialization
make (an_id: like id) do id := an_id end
feature -- Access
id: INTEGER
Max_run_count: INTEGER = 20
is_running: BOOLEAN
feature -- Element change
run local l_i: INTEGER l_track: STRING do from is_running := True l_i := 0 l_track := "" until l_i = Max_run_count loop l_track.append ("*") io.put_string ("id: " + id.out + "--->" + l_track + "%N") delay (500)
l_i := l_i + 1 end is_running := False end
feature {NONE} -- Timing
delay (milliseconds: INTEGER_64) -- Delay execution by `milliseconds'. do (create {EXECUTION_ENVIRONMENT}).sleep (milliseconds * 1_000_000) end
end
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/08f6cc67-4aa4-4536-b883-5be6e173b3e9%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/08f6cc67-4aa4-4536-b883-5be6e173b3e9%40googlegroups.com.
-- Make all horses run. across horses is l_horse_item loop separate l_horse_item as l_horse_sep do l_horse_sep.run -- 1) till this call is not finished, the following separate instruction will be blocked??? end end io.put_string (" ---------> All horses started%N")
-- Show status of run across 1 |..| 15 is l_status_show_runs loop io.put_string ("------------ Race status ---------------------------------%N") -- Show status of the horses across horses is l_horse_item loop separate l_horse_item as l_horse_sep do -- 1) question is it blocked till the l_horse_sep.run finishes? io.put_string ("Getting horse (" + l_horse_sep.id.out + ") out %N") create l_s.make_from_separate (l_horse_sep.out) io.put_string (l_s + "%N") end end io.put_string ("------------------End race status ---------------------------%N") wait (300) end
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-389118f7-10b1-49ce-a3e1-9f7e16945cd0-1581607116656%403c-app-gmx-bap11.
***** STATUS START ****************1) speed (35) pos (3) -->__*_____________<---2) speed (69) pos (8) -->______*_________<---3) speed (64) pos (14) -->______________*<---4) speed (21) pos (13) -->_____________*_<---5) speed (99) pos (9) -->_________*_____<---***** STATUS END ****************
***** STATUS START ****************Philosopher 1: eatingPhilosopher 2: thinkingPhilosopher 3: eatingPhilosopher 4: thinkingPhilosopher 5: thinking***** STATUS END ****************
karsten...@gmx.de:
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-843e8e79-fbf1-4796-93b1-05d8dc62a4a1-1581787533694%403c-app-gmx-bap18.
Воскресенье, 16 февраля 2020, 10:29 +03:00 от karsten...@gmx.de:
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-1705c2a0-75ab-49e5-bba0-4724b82ebd0c-1581838162374%403c-app-gmx-bs20.
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-843e8e79-fbf1-4796-93b1-05d8dc62a4a1-1581787533694%403c-app-gmx-bap18.
class APPLICATION
inherit FACILITY_USER
create make
feature {NONE} -- Initialization
make local
l_finished: BOOLEAN l_horse: like horses.item l_s: STRING l_displayer: separate STATUS_DISPLAYER[like horses.item] do io.put_string ("************** Race start ****************** %N") set_random
-- Put all horses in the turf. create horses.make create l_displayer.make (horses)
separate horses as l_horses_sep, l_displayer as l_displayer_sep do
across 1 |..| 5 is l_horse_id loop
random.forth create l_horse.make (l_horse_id, random.item \\ {HORSE}.Max_speed + 1) l_horses_sep.extend (l_horse) end
l_displayer_sep.set_show_status (True)
io.put_string (" ---------> Starting all horses%N")
-- Make all horses run.
across
l_horses_sep is l_horse_item
loop separate l_horse_item as l_horse_sep do l_horse_sep.run
end end io.put_string (" ---------> All horses started%N")
-- wait for finish from until all_horses_reached_end loop wait (1_000) end l_displayer_sep.set_show_status (False) end
io.put_string ("************** Race end ****************** %N%N") end
feature -- Access
horses: separate LINKED_LIST[separate HORSE]
random: RANDOM
feature {NONE} -- Implementation
set_random local l_random: RANDOM l_time: TIME do create l_time.make_now create random.make random.set_seed (l_time.milli_second \\ 100) random.forth end
all_horses_reached_end: BOOLEAN local l_s: STRING do Result := True separate horses as l_horses_sep do across l_horses_sep is l_horse_item until not Result
loop separate l_horse_item as l_horse_sep do
create l_s.make_from_separate (l_horse_sep.out) io.put_string ("all_horses_reached_end:" + l_s + "%N") Result := l_horse_sep.has_finished end end end end
@karsten...@gmx.deI'm on it too.... we'll se which of both horses between you and me will get it ;-) maybe {NONE}my current version is still on development onthe user_friendly_version branch
On Sat, Feb 15, 2020 at 2:25 PM <Karsten...@gmx.de> wrote:
Does anybody know how to send the escape sequences
that are listed at
https://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
to the console? I think this would help Philippe.
@Philippe: Your first version worked
because APPLICATION did NOT query the horses' states
while they were running.
THEY reported their status by themselves, instead.
As I am also new to SCOOP I do not know
if there is a kind of shared memory
where the horses could leave their status messages,
which then could be queried and displayed by APPLICATION
without waiting for the horses to finish their runs.
Best,
Karsten
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-843e8e79-fbf1-4796-93b1-05d8dc62a4a1-1581787533694%403c-app-gmx-bap18.
Gachoud Philippe <ph.ga...@gmail.com>:
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-843e8e79-fbf1-4796-93b1-05d8dc62a4a1-1581787533694%403c-app-gmx-bap18.
--**********************************************Philippe GachoudPuerto Williams 6657Las CondesSantiago de Chile
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/428b83a2-b885-41f4-b479-807b37b58696%40googlegroups.com.
-- wait for finish, if enabled horses don't run :-(-- from-- until-- all_horses_reached_end-- loop-- wait (1_000)-- end-- l_displayer_sep.set_show_status (False)
end
io.put_string ("************** Race end ****************** %N%N") end
io.put_string ("************** Race start ****************** %N") set_random
-- Put all horses in the turf. create horses.make create l_displayer.make (horses)
across 1 |..| 5 is l_horse_id loop random.forth create l_horse.make (l_horse_id, random.item \\ {HORSE}.Max_speed + 1)
separate horses as l_horses_sep do
l_horses_sep.extend (l_horse) end end
separate l_displayer as l_displayer_sep do l_displayer_sep.set_show_status (True) end
-- Make all horses run. io.put_string (" ---------> Starting all horses%N")
-- separate_do_all (horses, agent (l_item: separate like horses.item) do separate l_item as l_item_sep do l_item_sep.run end end) -- not working separate -- working
horses as l_horses_sep do across l_horses_sep is l_horse_item
loop separate l_horse_item as l_horse_sep do l_horse_sep.run end end end io.put_string (" ---------> All horses started%N")
-- wait for finish
-- from-- until-- all_horses_reached_end-- loop-- wait (1_000)-- end-- separate-- l_displayer as l_displayer_sep-- do-- l_displayer_sep.set_show_status (False)-- end
io.put_string ("************** Race end ****************** %N%N")
Понедельник, 17 февраля 2020, 20:26 +03:00 от karsten...@gmx.de:
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-a0f58906-62b1-4f1b-bc37-81a4d2ce9350-1581960402200%403c-app-gmx-bs80.
make local l_all_finished: BOOLEAN
l_horse: like horses.item l_s: STRING
l_displayer: STATUS_DISPLAYER[like horses.item] do set_random -- initializes random attribute io.put_string ("************** Race start ********************************************** %N")
-- Put all horses in the turf. create horses.make
across 1 |..| 5 is l_horse_id loop random.forth create l_horse.make (l_horse_id, random.item \\ {HORSE}.Max_speed + 1)
horses.extend (l_horse)
end
-- Make all horses run. io.put_string (" ---------> Starting all horses%N")
across horses is l_horse_item
loop separate l_horse_item as l_horse_sep do l_horse_sep.run end end io.put_string (" ---------> All horses started%N")
-- displayer create l_displayer.make (horses) io.put_string (" ---------> after l_displayer make%N") l_displayer.set_show_status (True) io.put_string (" ---------> after l_displayer set_show_status%N") -- never reached
from until all_horses_reached_end loop wait (1_000) end
io.put_string ("all_horses_reached_end after loop") l_displayer.set_show_status (False)
io.put_string ("************** Race end ******************************************************* %N%N") end
Horse Race: Scoop Vs EL_PROCEDURE_DISTRIBUTER
Looking at this thread I get the impression that Scoop is not
that intuitive or easy to understand. I present my own solution
using the class EL_PROCEDURE_DISTRIBUTER
from Eiffel-Loop. EL_PROCEDURE_DISTRIBUTER hides the trickly
implementation details of distributing work across a pool of
threads.
See classes HORSE_RACE_APP and HORSE.
Which do you think is the easiest to understand?
-- Finnian Reilly
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-6a1b8506-3742-47c8-8aa8-8fc5e1c6eb06-1582134932340%403c-app-gmx-bap22.
karsten...@gmx.de:
Gachoud Philippe <ph.ga...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/9b504a7d-6de4-4ee9-94e9-c575f76acd6a%40googlegroups.com.
git clone git://git.code.sf.net/p/eiffel-scoop-horse-run/code eiffel-scoop-horse-run-code
cd eiffel-scoop-horse-run-code/
git checkout user_friendly_version
Last time, when I tried to compile and run your example, it seemed to be working as expected. I was using the code from the link mentioned in your email. So, I was sure, everything is fine. If this is not true, would it be possible to have the source code with the problem?Alexander Kogtenkov
Gachoud Philippe <ph.g...@gmail.com>:
Dear Finnian,your example is amazing!! Thx a lot for this.Unfortunately what was intended for me and I think Karsten is to keep simple to understand scoop in its basics and in your example the underground things are hidden in your library. At first view, I'm unable to apply your example to my code to correct my error and being the goal for me of the horses_run to learn scoop I'm still stuck in a dead-lock I don't understand.In all cases I'll review your code and details which are always for me a source of inspiration.Many thx for the time you dedicated in helping us.
On Wednesday, February 19, 2020 at 2:00:46 PM UTC-3, Finnian Reilly wrote:Horse Race: Scoop Vs EL_PROCEDURE_DISTRIBUTER
Looking at this thread I get the impression that Scoop is not that intuitive or easy to understand. I present my own solution using the class EL_PROCEDURE_DISTRIBUTER from Eiffel-Loop. EL_PROCEDURE_DISTRIBUTER hides the trickly implementation details of distributing work across a pool of threads.
See classes HORSE_RACE_APP and HORSE.
Which do you think is the easiest to understand?
-- Finnian Reilly
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users+unsubscribe@googlegroups.com.
git clone https://git.code.sf.net/p/eiffel-scoop-horse-run/code eiffel-scoop-horse-run-code
git checkout dev
simple_horses_run local l_displayer: STATUS_DISPLAYER h1, h2: separate HORSE l_s: STRING do create horses.make -- for void Safety io.put_string ("************** simple_horses_run start ********************************************** %N") set_random
create h1.make (1, random.item \\ {HORSE}.Max_speed + 1) create h2.make (2, random.item \\ {HORSE}.Max_speed + 1) horses.extend (h1) horses.extend (h2) -- RUN separate h1 as l_h do io.put_string ("starting h1 run%N") l_h.run end io.put_string ("after h1 run%N") separate h2 as l_h do io.put_string ("starting h2 run%N") l_h.run end io.put_string ("after h2 run%N")
-- Displayer io.put_string ("creating l_displayer%N") create l_displayer.make (horses) l_displayer.io_show_status -- reached only when h1.run and h2.run procedure are finished and h1 and h1 are released io.put_string ("l_displayer after io_show_status%N")
io.put_string ("************** simple_horses_run end ********************************************** %N") end
Gachoud Philippe <ph.ga...@gmail.com>:
Gachoud Philippe <ph.g...@gmail.com>:
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/9b504a7d-6de4-4ee9-94e9-c575f76acd6a%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/f0991868-b972-481b-af17-e6e41bff5241%40googlegroups.com.
karsten...@gmx.de:
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-f6e23309-cdfe-42e5-aefd-aa5ddd67f862-1582388618528%403c-app-gmx-bap62.
Gachoud Philippe <ph.ga...@gmail.com>:
Gachoud Philippe <ph.g...@gmail.com>:
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/9b504a7d-6de4-4ee9-94e9-c575f76acd6a%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users+unsubscribe@googlegroups.com.
It should have happened long ago but eventually I will publish a book on SCOOP programming; these discussions are very useful to reflect what goes in the mind who start with the approach. Thanks too for making your code public.
-- BM
Gachoud Philippe <ph.ga...@gmail.com>:
Gachoud Philippe <ph.g...@gmail.com>:
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/9b504a7d-6de4-4ee9-94e9-c575f76acd6a%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/f0991868-b972-481b-af17-e6e41bff5241%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/dcb0b320-08ec-4195-b324-48a9d18d5923%40googlegroups.com.
git clone git://git.code.sf.net/p/eiffel-scoop-horse-run/code eiffel-scoop-horse-run-code;
git checkout state_objects_example
create l_displayer.make ( status_keepers, separate agent do io.put_string ("************** simple_horses_run end ****************** %N") end -- complaining here )
class STATUS_DISPLAYER
feature {NONE} -- Initialize
make (a_status_keepers: like status_keepers; a_all_horses_finished_agent: like all_horses_finished_agent) do create horses_ranking.make status_keepers := a_status_keepers all_horses_finished_agent := a_all_horses_finished_agent ensure status_keepers = a_status_keepers end
feature -- Access
all_horses_finished_agent: separate PROCEDURE[separate TUPLE] -- agent called by set_horse_position once all horses have finished running
Eric Bezault <er...@gobosoft.com>:
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-96f8894a-9e5f-4d1e-929d-f1c18e253717-1582642468600%403c-app-gmx-bap48.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/CAGh7wYEPm9toDg%2BpOrF230-npePtCVZTySG8KO3A6%3DBEF3AsXQ%40mail.gmail.com.
Dear Philippe,
I had a look at your design (and the cute horse images :)
and compared it with mine, see http://t1p.de/b64o
folder scoop_horses.zip\2020-02-26\Comparison.png).
@All: Please feel free to use the code in any way you want.
The main differences are:
1) In your system each horse has its own separate state keeper,
whereas in my system one single shared bus
(separate ARRAY [INTEGER]) takes this role.
2) In your system the number of rounds is defined in HORSE
and passed to the displayer during run time.
In my system constants are shared by inheriting from SHARED.
Thank you very much for your efforts and support.
@Alexander: The same to you!
I learned a lot!
Best,
Karsten
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/trinity-895ab253-59a5-41f4-ae13-082fa7c7e142-1582717782544%403c-app-gmx-bs21.