public LBMXSP onTransportMapping(LBMContext context, LBMNewTransportInfo newTransportInfo, Object cbArg) { printNewTransport(newTransportInfo); System.Console.Out.WriteLine("Applying 'round_robin' mapping."); LBMRoundRobinXSPEntry entry = xspEntries[counter]; if (entry.xsp == null) { System.Console.Out.WriteLine("Creating and using a new XSP at index: " + counter); createXSP(context, entry); } else { System.Console.Out.WriteLine("Using XSP at index: " + counter); } counter++; if (counter >= round_robin) { counter = 0; } return(entry.xsp); }
private static void createXSP(LBMContext ctx, LBMRoundRobinXSPEntry entry) { ThreadStart disp = delegate { while (entry.running) { entry.xsp.processEvents(500); } }; LBMXSPAttributes xattr = new LBMXSPAttributes(); xattr.setValue("operational_mode", sequential_xsps ? "sequential" : "embedded"); xattr.setZeroTransportsCallback(new LBMZeroTransportsCallback(onZeroTransports), entry); LBMContextAttributes cattr = new LBMContextAttributes(); entry.xsp = new LBMXSP(ctx, cattr, xattr); if (sequential_xsps) { entry.running = true; entry.dispatchThread = new Thread(disp); entry.dispatchThread.Start(); } }
public LBMRoundRobinXSPMappingHandler() { counter = 0; xspEntries = new LBMRoundRobinXSPEntry[round_robin]; for (int i = 0; i < round_robin; i++) { xspEntries[i] = new LBMRoundRobinXSPEntry(i); } }
private static void deleteXSP(LBMRoundRobinXSPEntry entry) { System.Console.Out.WriteLine("Deleting XSP at index: " + entry.index); if (sequential_xsps) { entry.running = false; entry.xsp.unblockProcessEvents(); entry.dispatchThread.Join(); entry.dispatchThread = null; } entry.xsp.close(); entry.xsp = null; }
public static int onZeroTransports(LBMXSP xsp, Object cbArg) { LBMRoundRobinXSPEntry entry = (LBMRoundRobinXSPEntry)cbArg; System.Console.Out.WriteLine("The number of transports has dropped to zero on the XSP at index: " + entry.index); if (defer_xsp_deletion) { /* since we're deferring the deletion of the XSP, we don't have to do anything here */ } else { deleteXSP(entry); } return(0); }