Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public abstract class WorkerBase<S, I, O> {
  2. public WorkerBase() { }
  3.  
  4. public virtual bool Initialize() {
  5. return true;
  6. }
  7.  
  8. public abstract List<O> Process(S settings, List<I> input);
  9. }
  10.  
  11. static ObjectPool<MyPool, MyPool.Settings, MyPool.Input, MyPool.Output> myPool = new ObjectPool<MyPool, MyPool.Settings, MyPool.Input, MyPool.Output>();
  12.  
  13. // Later...
  14. var output = myPool.Process(settings, input);
  15.  
  16. public class ObjectPool<T, S, I, O> where T : WorkerBase<S, I, O>, new() {
  17. /* Much implementation omitted for sake of clarity */
  18.  
  19. public List<O> Process(S settings, List<I> input) {
  20. // Indirectly calls worker's Process function
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement