/*
Copyright 2005-2014 Intel Corporation. All Rights Reserved.
This file is part of Threading Building Blocks. Threading Building Blocks is free software;
you can redistribute it and/or modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation. Threading Building Blocks is
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. You should have received a copy of
the GNU General Public License along with Threading Building Blocks; if not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
As a special exception, you may use this file as part of a free software library without
restriction. Specifically, if other files instantiate templates or use macros or inline
functions from this file, or you compile this file and link it with other files to produce
an executable, this file does not by itself cause the resulting executable to be covered
by the GNU General Public License. This exception does not however invalidate any other
reasons why the executable file might be covered by the GNU General Public License.
*/
/*
The original source for this example is
Copyright (c) 1994-2008 John E. Stone
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
package com.intel.tbb.example.tachyon;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Timer;
import java.util.TimerTask;
import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.content.Context;
import android.content.res.AssetManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
public class tachyon extends Activity {
private tachyonView myView;
private int W;
private int H;
private String fileOnSDcard;
private float currentYMenuPosition=(float) 1e5;
private float previousYMenuPosition=0;
public int number_of_threads=0;
public static TextView txtThreadNumber;
public static TextView txtElapsedTime;
private static native void setPaused(boolean paused);
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
fileOnSDcard = Environment.getExternalStorageDirectory()
.getPath() + "/tachyon/data.dat";
Log.i("tachyon", "Data file name is " + fileOnSDcard);
File dataFile = new File(fileOnSDcard);
if (dataFile.exists()) {
dataFile.delete();
}
if (!dataFile.exists()) {
AssetManager assetManager = getAssets();
InputStream inputFile = assetManager.open("data.dat");
dataFile.getParentFile().mkdirs();
dataFile.createNewFile();
OutputStream outputFile = new FileOutputStream(fileOnSDcard);
byte[] buffer = new byte[10000];
int bytesRead;
while ((bytesRead = inputFile.read(buffer)) != -1)
outputFile.write(buffer, 0, bytesRead);
inputFile.close();
inputFile = null;
outputFile.flush();
outputFile.close();
outputFile = null;
}
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
ActionBar actionBar = getActionBar();
actionBar.hide();
H = displayMetrics.heightPixels;
W = displayMetrics.widthPixels;
Log.i("tachyon", "displayMetrics.heightPixels: " + H);
Log.i("tachyon", "displayMetrics.widthPixels: " + W);
//uncomment to override scene size
int sceneWidth = 400;
float ratio = W>H?(float)(W)/H:(float)(H)/W;
W = sceneWidth;
H = (int) (W/ratio);
Log.i("tachyon", "Scene size is " + W + "*" + H );
} catch (Exception e) {
Log.e("tachyon", "Exception in file copy: " + e.getMessage());
}
myView = new tachyonView(this, W, H, fileOnSDcard);
setContentView(myView);
LinearLayout llThreadNumber = new LinearLayout(this);
txtThreadNumber = new TextView(this);
txtThreadNumber.setText("");
txtThreadNumber.setTextColor(0xFF00FF00);
txtThreadNumber.setScaleX(1);
txtThreadNumber.setScaleY(1);
txtThreadNumber.setPadding(10, 10, 10, 10);
llThreadNumber.setGravity(Gravity.TOP | Gravity.CENTER);
llThreadNumber.addView(txtThreadNumber);
this.addContentView(llThreadNumber,
new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
LinearLayout llElapsedTime = new LinearLayout(this);
txtElapsedTime = new TextView(this);
txtElapsedTime.setText("");
txtElapsedTime.setTextColor(0xFFFF0000);
txtElapsedTime.setScaleX(2);
txtElapsedTime.setScaleY(2);
txtElapsedTime.setPadding(10, 10, 40, 10);
llElapsedTime.setGravity(Gravity.TOP | Gravity.RIGHT);
llElapsedTime.addView(txtElapsedTime);
this.addContentView(llElapsedTime,
new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_screen_menu, menu);
return true;
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
currentYMenuPosition = event.getY();
if(event.getAction()==MotionEvent.ACTION_UP ){
ActionBar actionBar = getActionBar();
if (previousYMenuPosition < currentYMenuPosition){
actionBar.show();
}else{
actionBar.hide();
}
previousYMenuPosition = cu
没有合适的资源?快使用搜索试试~ 我知道了~
Intel TBB Library

共1406个文件
html:441个
h:169个
lib:148个


温馨提示
TBB,Thread Building Blocks,线程构建模块,是Intel公司开发的并行编程开发的工具。 OSCON 上,Intel 宣布,Threading Building Blocks,Intel 众多软件开发工具中的一个,open source了。协议是 GPLv2。 TBB 获得过 17 届 Jolt Productivity Awards,是一套C++模板库,和直接利用 OSAPI写程序的 raw thread 比,在并行编程方面提供了适当的抽象,当然还包括更多其他内容,比如 task 概念,常用算法的成熟实现,自动负载均衡特性还有不绑定 CPU 数量的灵活的可扩展性等等。STL之父,Alexander Stepanov对此评价不错,他说“Threading Building Blocks… could become a basis for the concurrency dimension of the C++ standard library”。其他 TBB 的早期用户,包括Autodesk,Sun,Red Hat, Turbo Linux 等亦然。现在 O’Reilly 已经出版了一本 Intel Threading Building Blocks: Outfitting C++ for Multi-core Processor Parallelism。 TBB 可以在Windows,Linux和 OSX 上运行,支持 Intel, Microsoft 和GNU工具,这就覆盖了绝大多数需求范围。
资源推荐
资源详情
资源评论














收起资源包目录





































































































共 1406 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15

github_24888943
- 粉丝: 0
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 上半年信息系统项目管理师下午案例分析含答案.doc
- 教务管理系统数据库设计.doc
- Apache-Kylin大数据驱动商务革新(1).pdf
- 企业员工年假统计表以及年假查询表(Excel表格通用模板).xlsx
- 网络营销与传统直销的整合策略分析.doc
- 西安欧亚学院门诊信息化系统解决方案(1).pptx
- 基于MATLAB+CPLEX的电力系统机组组合热备用优化调度研究
- 软件测试测试方案.doc
- 信息技术前沿物联网技术.pptx
- 应用文-网络保险的发展现状、前景、问题及对策[PDF].pdf
- 基于神经网络电阻点焊工艺参数优化.doc
- 多项目管理体系.ppt
- 数据挖掘与关联规则PPT课件.ppt
- 网络系统集成与综合布线课程设计方案模板.doc
- 基于神经网络的故障诊断技术研究与仿真论文.doc
- 基于单片机的PID温度控制毕业设计.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制

- 1
- 2
前往页