io.baltoro.client.WSSessions_old Maven / Gradle / Ivy
package io.baltoro.client;
public class WSSessions_old
{
/*
private static WSSessions sessions;
private Set set;
private Set busySessions;
private ConcurrentLinkedQueue freeSessions;
private WSSessions()
{
set = new HashSet<>();
busySessions = new HashSet<>();
freeSessions = new ConcurrentLinkedQueue<>();
}
public static WSSessions get()
{
if(sessions == null)
{
sessions = new WSSessions();
}
return sessions;
}
public void addSession(Session session)
{
freeSessions.add(session);
set.add(session);
}
int checkSessions()
{
if(StringUtil.isNullOrEmpty(set))
{
return 0;
}
else
{
return set.size();
}
}
Session getSessionForWork()
{
if(StringUtil.isNullOrEmpty(set))
{
freeSessions.clear();
busySessions.clear();
return null;
}
if(freeSessions.isEmpty())
{
return null;
}
Session session = freeSessions.poll();
busySessions.add(session);
return session;
}
void releaseSession(Session session)
{
freeSessions.add(session);
busySessions.remove(session);
String sync = "response-queue";
synchronized (sync.intern())
{
sync.intern().notify();
}
}
public void removeSession(Session session)
{
set.remove(session);
busySessions.remove(session);
freeSessions.remove(session);
if(set.size() == 0)
{
System.out.println("No running sessions plz restart the instance ");
System.exit(1);
}
}
*/
}