More atomic operations for user defined session attributes.
-----------------------------------------------------------
Key: DIRMINA-370
URL: https://issues.apache.org/jira/browse/DIRMINA-370
Project: MINA
Issue Type: New Feature
Components: Core
Reporter: Trustin Lee
Assigned To: Trustin Lee
Priority: Trivial
Fix For: 2.0.0-M1
MINA 1.1 and above uses ConcurrentHashMap in IoSession. ConcurrentMap has more
atomic operations than just Map; replace w/ oldValue, remove w/ value, and
putIfAbsent. We could expose these operations in IoSession, too.
A good example of the usage of these methods is
ProtocolCodecFilter.getDecoderLock().
private Object getDecoderLock( IoSession session )
{
Object lock = session.getAttribute( DECODER_LOCK );
if( lock == null )
{
lock = new Object();
session.setAttribute( DECODER_LOCK, lock );
}
return lock;
}
We could remove the possibility of returning different locks without a
synchronized block.
private Object getDecoderLock( IoSession session )
{
Object lock = session.getAttribute( DECODER_LOCK );
if( lock == null )
{
lock = session.setAttributeIfAbsent( DECODER_LOCK, new Object() );
}
return lock;
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.