This generator type abstracts the following type of generator:
More...
#include <GraphGenerators.hpp>
Inherits GeneratorType, and Showcase::Notifiable.
|
| virtual folly::Future< ValueType > | next (folly::Executor *executor=nullptr) override |
| |
| virtual void | changeObserved () override |
| |
template<typename GeneratorType>
class Showcase::CachingGenerator< GeneratorType >
This generator type abstracts the following type of generator:
- Generator can only read 'the whole state' of the target
- There is some external mechanism that is able to detect that change may have happened
The generator operates as following way:
- Read the whole state and return "found"-events for item followed by a pending event
- Hibernate into state where futures are returned if asked but never fulfilled
- When some external entity calls 'changeObserved'-event read the whole state again and fill as many futures with possible events as there exists
- If there are more events than there were futures, cache the events and hand them until there are no events cached anymore.
- Return to step 3.
This is used for example with FileSystem- and Database- generators
template<typename GeneratorType >
Only update cache if there are futures to be fulfilled
- Note
- assumption here is that this is called in some background thread so it should be ok to fulfill promises right here. on the other hand we could also put this to same executor which is given in next()-calls
template<typename GeneratorType >
| folly::Future< typename GeneratorType::ValueType > Showcase::CachingGenerator< GeneratorType >::next |
( |
folly::Executor * |
executor = nullptr | ) |
|
|
overridevirtual |
This function is only called by executor for this event if that is non null