From 661ee747a1677e2b1752e7b80eb949c8c1d022c9 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Thu, 13 Jan 2022 17:54:08 +0100 Subject: [PATCH] Create Pool-System with Lifetime --- docs/diagrams/class/Pool.puml | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 docs/diagrams/class/Pool.puml diff --git a/docs/diagrams/class/Pool.puml b/docs/diagrams/class/Pool.puml new file mode 100644 index 0000000..027f7c2 --- /dev/null +++ b/docs/diagrams/class/Pool.puml @@ -0,0 +1,67 @@ +@startuml +footer "LTDFS | Ruakij" + +header "" +title "Pool-System with Lifetime" + +enum ItemState { + WAITING + READY + TAKEN +} + +class "PoolItem" as PoolItem_T { + # item : T* + # aTime : std::chrono::time_point + # state : ItemState + -- + + PoolItem(T* item, ItemState state) +} +PoolItem_T "*" -> "1" ItemState : <> + +class "Pool" as Pool_T { + # min : uint + # max : uint + # idleLifetime : uint + .. + # {field} create : T*(*)() + # {field} isReady : boolean(*)(T*) + # {field} destroy : void(*)(T*) + .. + # items : Array + -- + + Pool(uint min, uint max, uint32_t lifetime, + T*(*create)(), + boolean(*isReady)(T*) = nullptr, + void(*destroy)(T*) = nullptr) + .. + + get() : T* + + return(T*) +} +note right of Pool_T::Pool + isReady: Checks if Object is ready + ItemState defaults to Ready if unset + + destroy: Destroy Object + defaults to delete/deconstructor +end note + +Pool_T "1" --> "*" PoolItem_T : <> + +class "PoolManager" as PoolManager_T { + # pools : Array>> + # thread : pthread_t + -- + + PoolManager(Array>> pools) + + PoolManager(Pool> pool) + .. + + Start() + + Stop() +} +note left of PoolItem_T::aTime +AccessTime +end note + +PoolManager_T "1" --> "*" Pool_T : <> + +@enduml \ No newline at end of file