关于DECAL(delphi 容器与算法库)的问题

jinkang 2003-09-29 03:32:59
decal我用了一下,是从C++的STL改写的,我用了一下,感觉不错。
但是有一个问题,就是在多线程时,在每个线程里创建一个(例如是MAP容器的类),每个线程的类里都做一个插入数据的过程。
在单线程时,这样使用都是正常的,但是在多线程时,插到几十万数据时,常常会内存访问错误。
我曾经问过作者Ross Judson,他的解释如下:

DeCAL was never designed to be multithreaded; you need to do your own locking around it if you are using it in this manner. There are both Delphi facilities and Windows calls that you can make to do this.

即DECAL不支持多线程,应当自己做处理。

但是,我在不同的线程中使用各自不同的类,这样怎么可能互相冲突?
真是没办法了,请各位帮忙。


关于decal的源码,请到以下地址下载:
http://sourceforge.net/projects/decal/
使用时只需包含decal.pas文件即可。不存在的文件直接注释即可。

附测试源码:我起8个线程,每个线程中执行以下MyTest过程。
procedure TmyTestThrd.MyTest;
const
MaxLoopTime = 100000;
var
myMap:DMap;
i:integer;
begin
myMap := DMap.Create;
try
for i := 0 to MaxLoopTime - 1 do
begin
myMap.putPair([i,inttostr(i)]);
end;
myMap.Free;
except
on a:exception do
begin
showmessage('error');
end;
end;
end;
...全文
139 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
he most complete mesh decal plugin available in the Asset Store since 2014. Used by professionals all around the world in hundreds of awesome projects. —————————————————— Forum | Issue Tracker | Online | Docs —————————————————— Want to try before buy? Download an evaluation version here! —————————————————— Easy Decal provides you with an easy-to-use workflow for putting decals on all types of surfaces in your game world. Enrich your virtual world with details and lift your game environment to the next level. Easy Decal not only supports diffuse textures and normal maps, but all kinds of shaders and materials. You can stick decals even to massively bumpy surfaces with ease – the dynamic geometry generator automatically adjusts all the necessary parameters (UVs, tangents, normals, etc.) in the blink of an eye. By using one tool, your decals will fit everywhere. Key Features • Works with all Unity Versions • Full editor integration • Custom materials and shaders • Contains ready-to-use prefabs • 80+ different decals included • 3D Projection (translation, rotation, scale) • Dynamic geometry • Texture Atlas Editor • Decal Animation • Edge Bleeding • Mesh Decals • Screen Space Decals • Screen Space Decals for LWRP/URP [BETA] • Deferred Decals • Static Mesh (Box/Mesh Collider needed) • Extensively tested with Oculus Rift SRP Support HDRP • Box Projector (mesh decal) • Plane Projector (mesh decal) • Unlit screen space (multiplicative) URP • Box Projector (mesh decal) • Plane Projector (mesh decal) • Lit screen space • Unlit screen space (multiplicative) Please note that not all new features are present in Unity versions smaller than 5.3. Source code is accessible on our website as additional download.

33,008

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧