added implementation details
This commit is contained in:
parent
323eb862c4
commit
8fd5f4530d
34
README.md
34
README.md
@ -243,7 +243,7 @@ But most importantly:
|
||||
|
||||
### Simulation iteration evaluation algorithm
|
||||
|
||||
- __MT__: main thread, controls the flow, HIGHEST PRIORITY
|
||||
- __MT__: manager/main thread, controls the flow, HIGHEST PRIORITY
|
||||
- __WT__: worker thread, evaluates a simulation iteration for one or more structures
|
||||
- __AT__: applier threads, applies actions and writes the `new stored signal` into the `current stored signal`
|
||||
for all blocks
|
||||
@ -275,3 +275,35 @@ It's probably not as fast as it gets, but it should be decent
|
||||
so that the process can be easily accomplished in multithreading execution environments.
|
||||
|
||||
__Note:__ the bigger a machine, the slower it reacts to inputs because signals need more time to travel through the body
|
||||
|
||||
### Structs, traits and methods
|
||||
|
||||
- world (class), keeps all information about a world
|
||||
- structure (trait)
|
||||
- compute(), computes an iteration of the simulation for this structure
|
||||
- get_blocks(), returns an immutable reference to the blocks
|
||||
- clean(), used to clear event queue, also calls clean() on blocks
|
||||
- runnable (trait)
|
||||
- run(), does stuff, mostly in another thread
|
||||
- manager (impls runnable), manages a world
|
||||
- worker (impls runnable), operates a list of creatures in a world
|
||||
- applier (impls runnable), operates on a list of creatures in a world, also calls clean() on structures
|
||||
- block (trait)
|
||||
- get_connections(), returns an immutable reference to the connection vector
|
||||
- get_value(), returns an immuatable reference to the current stored signal
|
||||
- get_name(), returns an immutable reference to the block's name
|
||||
- compute(), computes an iteration of the simulation for this block, then stores it in the new stored signal.
|
||||
also returns a list of actions that the block wants to perform
|
||||
- clean(), clears event queue and writes new stored signal into the current stored signal
|
||||
- action (trait)
|
||||
- get_source(), get the source structure (immutable ref)
|
||||
- get_target(), get the target (immutable ref)
|
||||
- apply(), applies the action
|
||||
|
||||
PROBLEM: apply() requires a mutable reference to the target, but it's not possible to pass it in any way. Only an
|
||||
immutable ref can be passed.
|
||||
|
||||
SOLUTION: use an immutable reference and call as_mut on it?
|
||||
|
||||
TODO: figure out where to put UI logic. We probably can't do it in parallel with the simulation, so it needs
|
||||
to be executed by the manager thread.
|
||||
|
Loading…
Reference in New Issue
Block a user