/** * <summary>All packets that come to this are demultiplexed according to t. * To subscribe or unsubscribe, get the ISource for the type you want and * subscribe to it,</summary> * <param name="t">The key for the MultiSource.</param> */ public ISource GetTypeSource(Object t) { //It's safe to get from a Hashtable without a lock. ISource s = (ISource)_subscription_table[t]; if (s == null) { lock ( _sync ) { //Since we last checked, there may be a ISource from another thread: s = (ISource)_subscription_table[t]; if (s == null) { s = new MultiSource(); _subscription_table[t] = s; } } } return(s); }
/** <summary>All packets that come to this are demultiplexed according to t. To subscribe or unsubscribe, get the ISource for the type you want and subscribe to it,</summary> <param name="t">The key for the MultiSource.</param> */ public ISource GetTypeSource(Object t) { //It's safe to get from a Hashtable without a lock. ISource s = (ISource)_subscription_table[t]; if( s == null ) { lock( _sync ) { //Since we last checked, there may be a ISource from another thread: s = (ISource)_subscription_table[t]; if( s == null ) { s = new MultiSource(); _subscription_table[t] = s; } } } return s; }