h*d0.1.0.0 Safe-Inferred %&'1 memory-poolThread-safe lock-free memory pool for managing large memory pages that are made up of many small s. memory-poolInitial page, which itself contains references to subsequent pages  memory-poolPage initializing action  memory-pool3Finilizer that will be attached to each individual   of a reserved .  memory-poolInternal helper type that manages each individual page. This is essentially a mutable linked list, which contains a memory buffer, a bit array that tracks which blocks in the buffer are free and which ones are taken.  memory-pool?Contiguous memory buffer that holds all the blocks in the page. memory-poolWe use an Int array, because there are no built-in atomic primops for Word. memory-poolThis is a boolean flag which indicates when a page is full. It here as optimization only, because it allows us to skip iteration of the above bit array. It is an  instead of a , because GHC provides atomic primops for ByteArray, whcih is what  is based on. memory-pool:Link to the next page. Last page when this IORef contains  memory-poolThis is just a proxy type that carries information at the type level about the size of the block in bytes supported by a particular instance of a . Use ) to get the byte size at the value level. memory-poolNumber of bytes in a  memory-poolUseful function for testing. Check how many pages have been allocated thus far. memory-poolInitilizes the , that can be used for further allocation of    n with . memory-pool Reserve a   of the  size in the 0. There is a default finalizer attached to the   that will run  pointer finalizer and release that memory for re-use by other blocks allocated in the future. It is safe to add more Haskell finalizers with  if necessary. memory-pool/This is a helper function that will allocate a   if the current   in the  is full. Whenever there are still block slots are available then supplied grabNext3 function will be used to reserve the slot in that  . memory-poolThis is a helper function that will attempt to find the next available slot for the  and create a   with the size of  in the  . In case when   is full it will return . memory-pool&Atomically AND an element of the array memory-pool)Atomically modify an element of the array memory-poolHelper function that finds an index of the left-most bit that is not set. memory-poolFinds an index of the next bit that is not set in the bit array and flips it atomically. In case when all bits are set, then  is returned. It is possible that while search is ongoing bits that where checked get cleared. This is totally fine for our implementation of mempool. memory-poolNumber of groups per page. Must be a posititve number, otherwise error. One group contains as many blocks as the operating system has bits. A 64bit architecture will have 64 blocks per group. For example, if program is compiled on a 64 bit OS and you know ahead of time the maximum number of blocks that will be allocated through out the program, then the optimal value for this argument will maxBlockNum/64 memory-poolMempool page allocator. Some allocated pages might be immediately discarded, therefore number of pages utilized will not necessesarely match the number of times this action will be called. memory-poolFinalizer to use for each block. It is an IO action because it will be executed by the Garbage Collector in a separate thread once the  is no longer referenced. memory-poolPage to grab the block from memory-poolFinalizer to run, once the   holding on to   is no longer used       !"# $%&*memory-pool-0.1.0.0-1645TVZRXynAUPzNcrf6mXSystem.Memory.Pool memory-poolPoolBlockblockByteCount countPagesinitPool grabNextBlockfindNextZeroIndex poolFirstPagepoolPageInitializerpoolBlockFinalizerbaseGHC.ForeignPtr ForeignPtrPage pageMemory pageBitArraypageFullghc-prim GHC.TypesIntBool#pvar-1.0.0.0-HzguFVoB19HHrQiA0K0n6CData.Primitive.PVar.InternalPVar pageNextPage GHC.MaybeNothingaddForeignPtrConcFinalizergrabNextPoolBlockWithgrabNextPageForeignPtratomicAndIntMutablePrimArrayatomicModifyMutablePrimArray setNextZeroGHC.PtrPtr