The requirement for core is, and will always be, that it can work without any 
additional libraries. In the places we use Thread Locals we would require that 
the Object Pooling logic be part of Log4j, not in another jar. 

Ralph


> On Jan 8, 2020, at 4:32 PM, Gary Gregory <garydgreg...@gmail.com> wrote:
> 
> Can we please not invent yet another pooling mechanism at Apache? ;-) OTOH
> bringing in Apache Commons Pool might be too heavy handed.
> 
> For the two main server stacks I work on at my day job, it's not an issue
> since I already use Commons Pool. Actually, now that I think of it: Commons
> DBCP (which depend on Commons Pool) is already an optional dependency for
> the JDBC Appender...
> 
> Discuss! :-)
> 
> Gary
> 
> On Wed, Jan 8, 2020 at 5:17 PM Volkan Yazıcı <volkan.yaz...@gmail.com>
> wrote:
> 
>> On Mon, Jan 6, 2020 at 7:09 PM Matt Sicker <boa...@gmail.com> wrote:
>>> Would it be useful to implement some sort of buffer pool for
>>> StringBuilders and ByteBuffers? Could likely copy code from netty's
>>> util library (ByteBuf et al.) or reuse stuff from commons-pool if
>>> needed. This would work properly in applications, servlets, and even
>>> reactive streams and lightweight threads later on.
>> 
>> Would you mind elaborating a little bit more on the idea you have in
>> mind, please? To get the discussion going, I have the following draft:
>> 
>>    public interface ObjectPool<V> {
>>        V acquire();
>>        void release(V instance);
>>    }
>> 
>>    public interface ObjectPoolFactory {
>>        // For char[], byte[], ByteBuffer, etc. (Types that cannot get
>> extended implicitly.)
>>        ObjectPool<V> create(Class<V> clazz, Supplier<V> objectFactory);
>>        // For StringBuilder, etc. (Types that can get extended
>> implicitly.)
>>        ObjectPool<V> share(Class<V> clazz);
>>    }
>> 
>> One can pretty efficiently implement such an ObjectPool<V>, e.g., via
>> a JCTools[1] MPMC queue. Though note that object pools necessitate
>> manual object release, which is not the case for TLA-provided objects.
>> 
>> Providing a shared object pool factory to the rest of the code base
>> might need a little bit more thinking.
>> 
>> Exposing configuration knobs to enforce certain limits on the pool and
>> its factory is also a question that needs to be addressed.
>> 
>> [1] https://github.com/JCTools/JCTools/
>> 


Reply via email to