当前位置: 首页>>代码示例>>Java>>正文


Java ConcurrentHashMap.newKeySet方法代码示例

本文整理汇总了Java中java.util.concurrent.ConcurrentHashMap.newKeySet方法的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentHashMap.newKeySet方法的具体用法?Java ConcurrentHashMap.newKeySet怎么用?Java ConcurrentHashMap.newKeySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.ConcurrentHashMap的用法示例。


在下文中一共展示了ConcurrentHashMap.newKeySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMobs

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
public Set<L2ControllableMobInstance> getMobs()
{
	if (_mobs == null)
	{
		_mobs = ConcurrentHashMap.newKeySet();
	}
	
	return _mobs;
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:10,代码来源:MobGroup.java

示例2: QueueHandler

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
private QueueHandler(Queue queue) {
    this.queue = queue;
    unmodifiableQueueView = new UnmodifiableQueueWrapper(queue);
    // TODO: take message count from queue configuration
    this.redeliveryQueue = new MemQueueImpl(queue.getName(), 1000, false);
    this.consumers = ConcurrentHashMap.newKeySet();
    consumerIterator = new CyclicConsumerIterator();

}
 
开发者ID:wso2,项目名称:message-broker,代码行数:10,代码来源:QueueHandler.java

示例3: Procedure

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
public Procedure(RegisterMessage registerMessage, long registrationId,
		boolean isDealerCallerIdentificationFeatureEnabled) {
	this.procedure = registerMessage.getProcedure();
	this.webSocketSessionId = registerMessage.getWebSocketSessionId();
	if (isDealerCallerIdentificationFeatureEnabled) {
		this.discloseCaller = registerMessage.isDiscloseCaller();
	}
	else {
		this.discloseCaller = false;
	}
	this.registrationId = registrationId;
	this.pendingInvocations = ConcurrentHashMap.newKeySet();
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:14,代码来源:Procedure.java

示例4: Subscription

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
Subscription(String topic, MatchPolicy matchPolicy, long subscriptionId) {
	this.createdTimeMillis = System.currentTimeMillis();

	this.topicMatch = new DestinationMatch(topic, matchPolicy);

	this.subscriptionId = subscriptionId;
	this.subscribers = ConcurrentHashMap.newKeySet();
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:9,代码来源:Subscription.java

示例5: addBlockedAbnormalTypes

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * Adds abnormal types to the blocked buff slot set.
 * @param blockedAbnormalTypes the blocked buff slot set to add
 */
public void addBlockedAbnormalTypes(Set<AbnormalType> blockedAbnormalTypes)
{
	if (_blockedAbnormalTypes == null)
	{
		synchronized (this)
		{
			if (_blockedAbnormalTypes == null)
			{
				_blockedAbnormalTypes = ConcurrentHashMap.newKeySet(blockedAbnormalTypes.size());
			}
		}
	}
	_blockedAbnormalTypes.addAll(blockedAbnormalTypes);
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:19,代码来源:CharEffectList.java

示例6: registerUser

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
    * Registeres the Learner for processing by SendWorker.
    */
   @OnOpen
   public void registerUser(Session session) throws IOException {
Long lessonId = Long.valueOf(session.getRequestParameterMap().get(AttributeNames.PARAM_LESSON_ID).get(0));
Set<Websocket> sessionWebsockets = PresenceWebsocketServer.websockets.get(lessonId);
if (sessionWebsockets == null) {
    sessionWebsockets = ConcurrentHashMap.newKeySet();
    PresenceWebsocketServer.websockets.put(lessonId, sessionWebsockets);
}
Websocket websocket = new Websocket(session);
sessionWebsockets.add(websocket);

Roster roster = PresenceWebsocketServer.rosters.get(lessonId);
if (roster == null) {
    boolean imEnabled = Boolean.valueOf(session.getRequestParameterMap().get("imEnabled").get(0));
    // build a new roster object
    roster = new Roster(lessonId, imEnabled);
    PresenceWebsocketServer.rosters.put(lessonId, roster);
}

new Thread(() -> {
    try {
	// websocket communication bypasses standard HTTP filters, so Hibernate session needs to be initialised manually
	HibernateSessionManager.openSession();
	SendWorker.send(lessonId, websocket.nickName);
    } finally {
	HibernateSessionManager.closeSession();
    }
}).start();

if (PresenceWebsocketServer.log.isDebugEnabled()) {
    PresenceWebsocketServer.log
	    .debug("User " + websocket.nickName + " entered Presence Chat with lesson ID: " + lessonId);
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:PresenceWebsocketServer.java

示例7: registerUser

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
    * Registeres the Learner for processing by SendWorker.
    */
   @OnOpen
   public void registerUser(Session session) throws IOException {
Long toolSessionId = Long
	.valueOf(session.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0));
Set<Websocket> sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId);
if (sessionWebsockets == null) {
    sessionWebsockets = ConcurrentHashMap.newKeySet();
    LearningWebsocketServer.websockets.put(toolSessionId, sessionWebsockets);
}
final Set<Websocket> finalSessionWebsockets = sessionWebsockets;

String userName = session.getUserPrincipal().getName();
new Thread(() -> {
    try {
	// websocket communication bypasses standard HTTP filters, so Hibernate session needs to be initialised manually
	HibernateSessionManager.openSession();
	ChatUser chatUser = LearningWebsocketServer.getChatService().getUserByLoginNameAndSessionId(userName,
		toolSessionId);
	Websocket websocket = new Websocket(session, chatUser.getNickname(), chatUser.getUserId(), getPortraitId(chatUser.getUserId()));
	finalSessionWebsockets.add(websocket);

	// update the chat window immediatelly
	SendWorker.send(toolSessionId);

	if (LearningWebsocketServer.log.isDebugEnabled()) {
	    LearningWebsocketServer.log
		    .debug("User " + userName + " entered Chat with toolSessionId: " + toolSessionId);
	}
    } finally {
	HibernateSessionManager.closeSession();
    }
}).start();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:LearningWebsocketServer.java

示例8: registerUser

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
    * Registeres the Learner for processing by SendWorker.
    */
   @OnOpen
   public void registerUser(Session websocket) throws JSONException, IOException {
Long toolSessionId = Long
	.valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0));
Set<Session> sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId);
if (sessionWebsockets == null) {
    sessionWebsockets = ConcurrentHashMap.newKeySet();
    LearningWebsocketServer.websockets.put(toolSessionId, sessionWebsockets);

    Map<Long, Map<Long, Boolean>> sessionCache = new TreeMap<>();
    LearningWebsocketServer.cache.put(toolSessionId, sessionCache);
}
sessionWebsockets.add(websocket);

if (LearningWebsocketServer.log.isDebugEnabled()) {
    LearningWebsocketServer.log.debug("User " + websocket.getUserPrincipal().getName()
	    + " entered Scratchie with toolSessionId: " + toolSessionId);
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:LearningWebsocketServer.java

示例9: registerUser

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
    * Registeres the Learner for processing by SendWorker.
    */
   @OnOpen
   public void registerUser(Session websocket) throws JSONException, IOException {
Long toolSessionId = Long
	.valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0));
Set<Session> sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId);
if (sessionWebsockets == null) {
    sessionWebsockets = ConcurrentHashMap.newKeySet();
    LearningWebsocketServer.websockets.put(toolSessionId, sessionWebsockets);
}
sessionWebsockets.add(websocket);

if (LearningWebsocketServer.log.isDebugEnabled()) {
    LearningWebsocketServer.log.debug("User " + websocket.getUserPrincipal().getName()
	    + " entered Scribe with toolSessionId: " + toolSessionId);
}

new Thread(() -> {
    try {
	HibernateSessionManager.openSession();
	SendWorker.send(toolSessionId, websocket);
    } catch (Exception e) {
	log.error("Error while sending messages", e);
    } finally {
	HibernateSessionManager.closeSession();
    }
}).start();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:LearningWebsocketServer.java

示例10: createsNewRule

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
@Test
public void createsNewRule() {
    final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder = getRuleSetBuilder();

    final DriverCache cache = new DriverCache();
    final Set<ValueGroup> groups = ConcurrentHashMap.newKeySet();
    final ValueGroup group = new ValueGroup("CMEGroup", Arrays.asList("CME", "CBOT"));
    groups.add(group);
    RuleSetBuilder.addValueGroupsToDriverCache(cache, groups);

    ruleSetBuilder.with(RuleSetBuilder::setCache, cache);
    ruleSetBuilder.with(RuleSetBuilder::groups, groups);
    this.ruleSet = ruleSetBuilder.build();

    this.builder = RuleChangeBuilder.creator(this.ruleSet, new UUID(0, 9));
    this.builder.with(RuleChangeBuilder::input,
            Arrays.asList("VOICE", "CME", "ED", "UK", GroupDriver.VG_PREFIX + group.getId()));
    this.builder.with(RuleChangeBuilder::output, Collections.singletonMap("Rate", "2.0"));
    this.builder.with(RuleChangeBuilder::changeRange,
            new DateRange(NOW.minus(Period.ofWeeks(1)), NOW.plus(Period.ofWeeks(1))));
    final List<RuleChange> ruleChanges = this.builder.build();
    assertThat(ruleChanges, hasSize(1));

    final RuleChange change = ruleChanges.get(0);
    assertEquals(Type.NEW, change.getType());

    assertRuleChange(change, Type.NEW, null, new UUID(0, 9),
            new String[]{"VOICE", "CME", "ED", "UK", GroupDriver.VG_PREFIX + group.getId().toString()},
            Collections.singletonMap("Rate", "2.0"), NOW.minus(Period.ofWeeks(1)),
            NOW.plus(Period.ofWeeks(1)));

    final List<String> driverValues =
            Arrays.stream(change.getRule().getDrivers()).map(InputDriver::toString).collect(Collectors.toList());
    assertThat(driverValues, contains("VOICE", "CME", "ED", "UK", GroupDriver.VG_PREFIX + group.getId()));
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:36,代码来源:RuleChangeBuilderTest.java

示例11: getStatusListener

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * Return the list of L2Character that must be informed of HP/MP updates of this L2Character.<br>
 * <B><U>Concept</U>:</B><br>
 * Each L2Character owns a list called <B>_statusListener</B> that contains all L2PcInstance to inform of HP/MP updates.<br>
 * Players who must be informed are players that target this L2Character.<br>
 * When a RegenTask is in progress sever just need to go through this list to send Server->Client packet StatusUpdate.
 * @return The list of L2Character to inform or null if empty
 */
public final Set<L2Character> getStatusListener()
{
	if (_StatusListener == null)
	{
		_StatusListener = ConcurrentHashMap.newKeySet();
	}
	return _StatusListener;
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:17,代码来源:CharStatus.java

示例12: getAttackByList

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * @return a list of L2Character that attacked.
 */
public final Set<WeakReference<L2Character>> getAttackByList()
{
	if (_attackByList == null)
	{
		synchronized (this)
		{
			if (_attackByList == null)
			{
				_attackByList = ConcurrentHashMap.newKeySet();
			}
		}
	}
	return _attackByList;
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:18,代码来源:L2Character.java

示例13: addToWaitingList

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
public void addToWaitingList(L2PcInstance player)
{
	if (_waitingList == null)
	{
		synchronized (this)
		{
			if (_waitingList == null)
			{
				_waitingList = ConcurrentHashMap.newKeySet(1);
			}
		}
	}
	_waitingList.add(player);
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:15,代码来源:MatchingRoomManager.java

示例14: populatedSet

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
static Set<Integer> populatedSet(int n) {
    Set<Integer> a = ConcurrentHashMap.<Integer>newKeySet();
    assertTrue(a.isEmpty());
    for (int i = 0; i < n; i++)
        assertTrue(a.add(i));
    assertEquals(n == 0, a.isEmpty());
    assertEquals(n, a.size());
    return a;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:ConcurrentHashMap8Test.java

示例15: JsonBackedNotifiersRepositoryImpl

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
@Autowired
public JsonBackedNotifiersRepositoryImpl(@Value("${notifiers.file}") File notifierFile, ObjectMapper objectMapper) throws IOException {
    this.notifierSet = ConcurrentHashMap.newKeySet();
    this.notifierFile = notifierFile;
    this.objectMapper = objectMapper;


    if (notifierFile.exists()) {
        loadFromFile();
    } else {
        notifierFile.createNewFile();
        writeToFile();
    }
}
 
开发者ID:gilles-stragier,项目名称:quickmon,代码行数:15,代码来源:JsonBackedNotifiersRepositoryImpl.java


注:本文中的java.util.concurrent.ConcurrentHashMap.newKeySet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。