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


Java WorkerCallback类代码示例

本文整理汇总了Java中edu.mit.csail.sdg.alloy4.WorkerEngine.WorkerCallback的典型用法代码示例。如果您正苦于以下问题:Java WorkerCallback类的具体用法?Java WorkerCallback怎么用?Java WorkerCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WorkerCallback类属于edu.mit.csail.sdg.alloy4.WorkerEngine包,在下文中一共展示了WorkerCallback类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import edu.mit.csail.sdg.alloy4.WorkerEngine.WorkerCallback; //导入依赖的package包/类
public void run(WorkerCallback out) throws Exception {
    this.out = out;
    cb("S2", "Enumerating...\n");
    A4Solution sol;
    Module mod;
    synchronized(SimpleReporter.class) {
        if (latestMetamodelXML!=null && latestMetamodelXML.equals(filename))
           {cb("pop", "You cannot enumerate a metamodel.\n"); return;}
        if (latestKodkodXML==null || !latestKodkodXML.equals(filename))
           {cb("pop", "You can only enumerate the solutions of the most-recently-solved command."); return;}
        if (latestKodkod==null || latestModule==null || latestKodkodSRC==null)
           {cb("pop", "Error: the SAT solver that generated the instance has exited,\nso we cannot enumerate unless you re-solve that command.\n"); return;}
        sol=latestKodkod;
        mod=latestModule;
    }
    if (!sol.satisfiable())
        {cb("pop", "Error: This command is unsatisfiable,\nso there are no solutions to enumerate."); return;}
    if (!sol.isIncremental())
        {cb("pop", "Error: This solution was not generated by an incremental SAT solver.\n" +
        "Currently only MiniSat and SAT4J are supported."); return;}
    int tries=0;
    while(true) {
        sol=sol.next();
        if (!sol.satisfiable())
           {cb("pop", "There are no more satisfying instances.\n\n" +
           "Note: due to symmetry breaking and other optimizations,\n" +
           "some equivalent solutions may have been omitted."); return;}
        String toString = sol.toString();
        synchronized(SimpleReporter.class) {
            if (!latestKodkods.add(toString)) if (tries<100) { tries++; continue; }
            // The counter is needed to avoid a Kodkod bug where sometimes we might repeat the same solution infinitely number of times; this at least allows the user to keep going
            writeXML(null, mod, filename, sol, latestKodkodSRC); latestKodkod=sol;
        }
        cb("declare", filename);
        return;
    }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:38,代码来源:SimpleReporter.java

示例2: SimpleReporter

import edu.mit.csail.sdg.alloy4.WorkerEngine.WorkerCallback; //导入依赖的package包/类
/** Constructor is private. */
private SimpleReporter(WorkerCallback cb, boolean recordKodkod) {
	this.cb = cb;
	this.recordKodkod = recordKodkod;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:6,代码来源:SimpleReporter.java

示例3: run

import edu.mit.csail.sdg.alloy4.WorkerEngine.WorkerCallback; //导入依赖的package包/类
public void run(WorkerCallback out) throws Exception {
	this.out = out;
	cb("S2", "Enumerating...\n");
	A4Solution sol;
	Module mod;
	synchronized (SimpleReporter.class) {
		if (latestMetamodelXML != null && latestMetamodelXML.equals(filename)) {
			cb("pop", "You cannot enumerate a metamodel.\n");
			return;
		}
		if (latestKodkodXML == null || !latestKodkodXML.equals(filename)) {
			cb("pop", "You can only enumerate the solutions of the most-recently-solved command.");
			return;
		}
		if (latestKodkod == null || latestModule == null || latestKodkodSRC == null) {
			cb("pop",
					"Error: the SAT solver that generated the instance has exited,\nso we cannot enumerate unless you re-solve that command.\n");
			return;
		}
		sol = latestKodkod;
		mod = latestModule;
	}
	if (!sol.satisfiable()) {
		cb("pop", "Error: This command is unsatisfiable,\nso there are no solutions to enumerate.");
		return;
	}
	if (!sol.isIncremental()) {
		cb("pop", "Error: This solution was not generated by an incremental SAT solver.\n"
				+ "Currently only MiniSat and SAT4J are supported.");
		return;
	}
	int tries = 0;
	while (true) {
		sol = sol.next();
		if (!sol.satisfiable()) {
			cb("pop",
					"There are no more satisfying instances.\n\n"
							+ "Note: due to symmetry breaking and other optimizations,\n"
							+ "some equivalent solutions may have been omitted.");
			return;
		}
		String toString = sol.toString();
		synchronized (SimpleReporter.class) {
			if (!latestKodkods.add(toString))
				if (tries < 100) {
					tries++;
					continue;
				}
			// The counter is needed to avoid a Kodkod bug where
			// sometimes we might repeat the same solution infinitely
			// number of times; this at least allows the user to keep
			// going
			writeXML(null, mod, filename, sol, latestKodkodSRC);
			latestKodkod = sol;
		}
		cb("declare", filename);
		return;
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:60,代码来源:SimpleReporter.java

示例4: cb

import edu.mit.csail.sdg.alloy4.WorkerEngine.WorkerCallback; //导入依赖的package包/类
public void cb(WorkerCallback out, Object... objs) throws IOException {
	out.callback(objs);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:4,代码来源:SimpleReporter.java

示例5: SimpleGUI

import edu.mit.csail.sdg.alloy4.WorkerEngine.WorkerCallback; //导入依赖的package包/类
/** The constructor; this method will be called by the AWT event thread, using the "invokeLater" method. */
private SimpleGUI (final String[] args) {

    // Register an exception handler for uncaught exceptions
    MailBug.setup();

    // Enable better look-and-feel
    if (Util.onMac() || Util.onWindows()) {
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Alloy Analyzer "+Version.version());
        System.setProperty("com.apple.mrj.application.growbox.intrudes","true");
        System.setProperty("com.apple.mrj.application.live-resize","true");
        System.setProperty("com.apple.macos.useScreenMenuBar","true");
        System.setProperty("apple.laf.useScreenMenuBar","true");
        try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Throwable e) { }
    }

    // Figure out the desired x, y, width, and height
    int screenWidth=OurUtil.getScreenWidth(), screenHeight=OurUtil.getScreenHeight();
    int width=AnalyzerWidth.get();
    if (width<=0) width=screenWidth/10*8; else if (width<100) width=100;
    if (width>screenWidth) width=screenWidth;
    int height=AnalyzerHeight.get();
    if (height<=0) height=screenHeight/10*8; else if (height<100) height=100;
    if (height>screenHeight) height=screenHeight;
    int x=AnalyzerX.get(); if (x<0) x=screenWidth/10; if (x>screenWidth-100) x=screenWidth-100;
    int y=AnalyzerY.get(); if (y<0) y=screenHeight/10; if (y>screenHeight-100) y=screenHeight-100;

    // Put up a slash screen
    final JFrame frame = new JFrame("Alloy Analyzer");
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.pack();
    if (!Util.onMac() && !Util.onWindows()) {
       String gravity = System.getenv("_JAVA_AWT_WM_STATIC_GRAVITY");
       if (gravity==null || gravity.length()==0) {
          // many Window managers do not respect ICCCM2; this should help avoid the Title Bar being shifted "off screen"
          if (x<30) { if (x<0) x=0; width=width-(30-x);   x=30; }
          if (y<30) { if (y<0) y=0; height=height-(30-y); y=30; }
       }
       if (width<100) width=100;
       if (height<100) height=100;
    }
    frame.setSize(width,height);
    frame.setLocation(x,y);
    frame.setVisible(true);
    frame.setTitle("Alloy Analyzer "+Version.version()+" loading... please wait...");
    final int windowWidth = width;
    // We intentionally call setVisible(true) first before settings the "please wait" title,
    // since we want the minimized window title on Linux/FreeBSD to just say Alloy Analyzer

    // Test the allowed memory sizes
    final WorkerEngine.WorkerCallback c = new WorkerEngine.WorkerCallback() {
        private final List<Integer> allowed = new ArrayList<Integer>();
        private final List<Integer> toTry = new ArrayList<Integer>(Arrays.asList(256,512,768,1024,1536,2048,2560,3072,3584,4096));
        private int mem;
        public synchronized void callback(Object msg) {
            if (toTry.size()==0) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() { SimpleGUI.this.frame=frame; SimpleGUI.this.finishInit(args, allowed, windowWidth); }
                });
                return;
            }
            try { mem=toTry.remove(0); WorkerEngine.stop(); WorkerEngine.run(dummyTask, mem, 128, "", "", this); return; } catch(IOException ex) { fail(); }
        }
        public synchronized void done() {
            //System.out.println("Alloy4 can use "+mem+"M"); System.out.flush();
            allowed.add(mem);
            callback(null);
        }
        public synchronized void fail() {
            //System.out.println("Alloy4 cannot use "+mem+"M"); System.out.flush();
            callback(null);
        }
    };
    c.callback(null);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:76,代码来源:SimpleGUI.java

示例6: SimpleReporter

import edu.mit.csail.sdg.alloy4.WorkerEngine.WorkerCallback; //导入依赖的package包/类
/** Constructor is private. */
private SimpleReporter(WorkerCallback cb, boolean recordKodkod) { this.cb=cb; this.recordKodkod=recordKodkod; }
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:3,代码来源:SimpleReporter.java

示例7: cb

import edu.mit.csail.sdg.alloy4.WorkerEngine.WorkerCallback; //导入依赖的package包/类
public void cb(WorkerCallback out, Object... objs) throws IOException { out.callback(objs); } 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:2,代码来源:SimpleReporter.java


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