在四核机器上,我正在考虑C#/ .NET算法的并行化,它涉及让多个线程同时读取小型int []数组.到目前为止,它似乎运行得相当好,但我不确定在哪里指定数组上的并发读取在.NET中是线程安全的.有什么指针吗?
然后,我也想知道这种方法是否真的有效?有没有你最好实际复制每个线程的输入数据,以便没有任何并发读取,每个阵列(可能?)有机会在亲和CPU附近缓存?
关于多核CPU的最佳实践的任何想法?
我有一个用Delphi 2006编写的应用程序在Windows XP中运行良好.我使用Inno Setup打包应用程序,使用Program Files作为默认文件夹.一些用户迁移到Windows Vista和Windows 7.这里的问题是应用程序在其安装文件夹中创建了一些文件.这在XP中有效但在Windows Vista中用户遇到了创建文件的问题(它们没有出现等等).在调查用户的报告后,我发现KB 927387:"Windows Vista或Windows 7中的常见文件和注册表虚拟化问题".
使用管理员权限运行应用程序只是解决了问题,但这是(我认为)一个糟糕的解决方法.我想知道是否有任何指令或技巧使应用程序与Vista和7兼容,因为更多用户将很快迁移到这些操作系统.
我正在玩DxScene和VxScene:http://www.ksdev.com/dxscene/index.html
它看起来非常漂亮和强大:3D加速矢量图形,交叉平台,漂亮的效果,许多2D控制(基于矢量),良好的缩放,透明度,旋转(x,y,z),3D模型等.即使有很多效果,CPU保持很低(0%)! http://www.ksdev.com/dxscene/snapshot/screen0.jpeg
但它可以被视为Delphi的一个好的WPF替代品吗?
有没有人用它而不是普通的Delphi VCL?
我在我的Mac上有一个由GCC编译的x86_64库,我想将它与使用Free Pascal 2.4编译的Pascal代码链接.我可以使用哪些选项fpc来生成64位代码?没有任何选项,我只获得32位.o文件.
我正在使用来自SourceForge 的fpc-2.4.0.intel-macosx.dmg下载,但是当我运行时fpc -i,它列出的唯一目标Macintosh平台是"Darwin for i386",尽管2.4版本说明它可以定位"64 -bit Mac OS X(x86_64/ppc64)."
我有std::map<int, std::pair<short, float> >,我需要short在这张地图中找到最小值.我该怎么boost::bind用std::min_element()?
boost::lambda?
我正在使用C++输出一个无符号字符数组,ofstream fout("filename");
但它会产生一个虚假字符.这是导致问题的代码的一部分:
for(int i = 0; i < 12; i++)
fout << DChuffTable[i];
Run Code Online (Sandbox Code Playgroud)
这是数组的定义:
unsigned char DChuffTable[12] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B};
Run Code Online (Sandbox Code Playgroud)
在输出文件,我收到了虚假0x0D之间0x09和0x0A.我在调试模式中检查了数组,然后才开始打印并且没有更改.请告诉我你对这个问题的看法.
我正在尝试编写一个用Borland C++和Visual C++编写的程序.为此,我在VS下编译源时添加#ifdef _MSC_VER包含stdafx.h文件.代码在Borland C++中编译并执行OK,但在VS中,它失败了:
错误C1020:意外#endif
#ifdef _MSC_VER //I'm in VS
#include "stdafx.h"
#endif //this line doesn't compile in VS
#ifdef __BORLANDC__ //I'm in Borland
#pragma hdrstop
#pragma argsused
#endif
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << "Hello" << std::endl;
std::cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个错误?
c++ compiler-errors c++builder conditional-compilation visual-studio
我对Delphi很新,并收到了以下代码(省略了一些不相关的部分),我正试图了解它的作用:
object SelectCosts: TIBQuery
SQL.Strings = (
'SELECT * FROM costs '
'WHERE code = :code')
ParamData = <
item
DataType = ftUnknown
Name = 'code'
ParamType = ptUnknown
end>
end
Run Code Online (Sandbox Code Playgroud)
在另一个文件中,使用该查询,但添加了未在查询中定义的参数.
DM_HRV.SelectCosts.ParamByName('part').Value := 1;
Run Code Online (Sandbox Code Playgroud)
此参数是否会'part'改变所做的选择?换句话说:SQL查询是否自动更改为以下内容?
'SELECT * FROM costs '
'WHERE code = :code'
'AND part = :part'
Run Code Online (Sandbox Code Playgroud) 有一个例子说明了我的问题:
procedure Test;
begin
try
ShowMessage('1');
raise EWarning.Create(12345, 'Warning: something is happens!');
ShowMessage('2');
except
on E: EWarning do
if IWantToContinue(E.ErrorCode) then
E.SkipThisWarning // shows '1' then '2'
else
E.StopExecution; // shows '1'
end;
end;
function IWantToContinue(const ErrorCode: Integer): Boolean;
begin
//...
end;
Run Code Online (Sandbox Code Playgroud)
我试着用这样的东西:
asm
jmp ExceptAddr
end;
Run Code Online (Sandbox Code Playgroud)
但它不会工作......
有任何想法吗?
谢谢.
我的代码有问题,它使用泛型类型.为什么编译器不知道传递的list(Result)是一个TObjectList<TItem>(TItem是Tin的类型TItems)?
接口:
type
TItem = class
end;
type
IItemsLoader = interface
procedure LoadAll(AList : TObjectList<TItem>);
end;
type
TItemsLoader = class(TInterfacedObject, IItemsLoader)
public
procedure LoadAll(AList : TObjectList<TItem>);
end;
type
IItems<T : TItem> = interface
function LoadAll : TObjectList<T>;
end;
type
TItems<T : TItem> = class(TInterfacedObject, IItems<T>)
private
FItemsLoader : TItemsLoader;
public
constructor Create;
destructor Destroy; override;
function LoadAll : TObjectList<T>;
end;
Run Code Online (Sandbox Code Playgroud)
执行:
procedure TItemsLoader.LoadAll(AList: TObjectList<TItem>);
begin
/// some stuff with AList …Run Code Online (Sandbox Code Playgroud) delphi ×5
c++ ×3
.net ×1
64-bit ×1
arrays ×1
boost-bind ×1
boost-lambda ×1
c++builder ×1
exception ×1
freepascal ×1
generics ×1
macos ×1
multicore ×1
ofstream ×1
tobjectlist ×1
vector ×1
windows ×1
windows-7 ×1
wpf ×1