zoukankan      html  css  js  c++  java
  • 用actor model实现intel tbb这样的用法

    关于什么事actor model,什么事intel tbb这样的用法我就不详细说了,具体请上网查文档

    	
    class MyActor
    {
    	F f;
    	MyActor inputs[];
    	MyActor outputs[];
    	int n;
    	
    	
    	#internal
    	void run()
    	{
    		f();
    		for o in outputs:
    			sendMsg(o, this)
    	}
    	
    	##1
    	void addOutput(o)
    	{
    		outputs.append(o);
    	}
    	
    	##2
    	void onFirstRun()
    	{
    		if inputs.empoty()
    			run()
    	}
    	
    	##3
    	void onMsg(id)
    	{
    		n++;
    		if(n==inputs.size()) 
    			run()
    			
    	}
    }
    
    def task(g, f, dependencies)
    {
    	a= MyActor(f, dependencies);
    	
    	// Tell dependencies add this actor to trigger list
    	for depend in dependencies:
    		depend.addOutput(a)
    		
    	return a
    }
    
    t1 = task([](){hello});
    t2 = task([](){world}, t1);
    g.run()
    

      

  • 相关阅读:
    序列化
    cookie 和 session
    a 标签提交表单
    SpringBoot使用Easypoi导出excel示例
    PDF操作类库 iText
    HandlerInterceptor
    Fastdfs
    InitializingBean
    CORS CorsFilter
    XMLHttpRequest
  • 原文地址:https://www.cnblogs.com/cutepig/p/6848643.html
Copyright © 2011-2022 走看看