DLL和线程的问题(Problems with DLL & threads)
请帮我解决以下问题:
我实现了一个线程做一些工作。 该线程隐式调用一些外部DLL。 当然,我尽力处理这些DLL中的可能错误(使用try ... catch)但无法处理意外错误(例如内存异常)。
如果其中一个DLL遇到问题(bug或循环某处)并最终卡住,则该线程将永远不会完成(或关闭)。
在我的程序中,每个线程都与一个会话相关联(会话数量有限)。 假设所有线程都被卡住,传入的会话将不得不永远等待。
有没有办法强制线程停止,即使它仍在工作或卡住?
请注意,我正在使用Boost库进行C ++编程。
欢迎任何建议!
提前致谢!
Please help me the following problems:
I implement a thread doing some jobs. This thread implicitly calls some external DLLs. Of course, I tried my best to handle possible errors in those DLLs (using try ... catch) but cannot handle unexpected errors (e.g. memory exception).
If one of DLLs encounters problem(s) (bug or loop somewhere) and eventually gets stuck, this thread will never be completed (or close).
In my program, each thread is associated with a session (number of sessions is limited). Assume all threads get stuck, incoming session will have to wait forever.
Is there any way to force a thread to stop even if it is still working or gets stuck?
Note that I am using C++ programming with Boost library.
Any advises are welcome!
Thanks in advance!
原文:https://stackoverflow.com/questions/21129916
最满意答案
这对我来说是一个艰难的问题,但你可能会考虑下面的结构:
Entity --------- EntityId ProfileId --nullable UserId --nullable RightsSet ---------- EntityId CanView CanEdit ObjectTypeID ObjectID
使用此方法,您可以在
Entity
表中的ProfileId
和UserId
上指定UNIQUE
约束,然后根据需要在RightsSet
创建RightsSet
记录。 当Entity
中的ProfileId
和UserId
都为null或者它们都具有值时,可能存在两个问题。 您可以在插入记录之前进行一些验证,以确保不会发生这种情况。This was a tough one for me to wrap my head around but you might consider the structure below:
Entity --------- EntityId ProfileId --nullable UserId --nullable RightsSet ---------- EntityId CanView CanEdit ObjectTypeID ObjectID
With this method you can specify a
UNIQUE
constraint onProfileId
andUserId
in theEntity
table and then create as many records inRightsSet
as is needed. Two possible problems would be whenProfileId
andUserId
inEntity
are both null or when they both have values. You could probably do some validation before you insert records to ensure this does not happen.
相关问答
更多-
多对多的关系往往会发展藤壶 - 与关系本身相关的额外数据,而不是关系中的任何一方(根据我的经验,这是常态而非例外)。 例如,成员和组可能以多对多的方式关联,并且您想知道某个成员加入某个组的时间,他们的成员状态(新建,挂起,暂停,等等)等等。 如果您从多对多直接建模关系开始,并相应地编写所有代码,则第一个加入连接表的额外列将会破坏您的模型和一堆代码。 Many-to-many relationships quite often develop barnacles — extra data that is as ...
-
您必须使用InverseProperty ,如下所示。 [InverseProperty("allClassB")] public virtual ClassB currentClassB { get; set; } public int? currentClassBID { get; set; } DataAnnotations - InverseProperty属性: You have to use InverseProperty as shown below. [InverseProperty("a ...
-
一对多 :一个人有很多技能,一个技能不会重复使用在人之间, 单向 :一个人可以通过它的Set直接引用技能 双向 :每个“孩子”技能有一个单一的指针回到人(在您的代码中未显示) 多对多 :一个人有很多技能,一个技能在人 单向 :一个人可以通过它的Set直接引用技能 双向 :技能有一组与之相关的人员。 在一对多关系中,一个对象是“父”,一个是“小孩”。 父母控制孩子的存在。 在“多对多”中,任何一种类型的存在都取决于它们之间的东西(在较大的应用程序上下文中)。 您的主题(域)应该决定关系是一对多还是多对多 - ...
-
一对一:使用外键引用表: student: student_id, first_name, last_name, address_id address: address_id, address, city, zipcode, student_id # you can have a # "link back" if you need 一对多 :使用外键链接到“一”方面的关系: teachers: ...
-
多对多而不是一对多(many-to-many instead of one-to-many)[2023-09-03]
您的JPA提供程序会创建其他表( author_email和author_phone ),因为您有双向关系,但未指出这些关系的哪一方是所有者( mappedBy属性)。 对Author类中的集合进行以下更改,它应该按预期工作。 @OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER, mappedBy = "author") private Setphones; @OneToMany(cascade = Casca ... -
一对多还是多对多?(One-to-many or many-to-many?)[2023-10-20]
这对我来说是一个艰难的问题,但你可能会考虑下面的结构: Entity --------- EntityId ProfileId --nullable UserId --nullable RightsSet ---------- EntityId CanView CanEdit ObjectTypeID ObjectID 使用此方法,您可以在Entity表中的ProfileId和UserId上指定UNIQUE约束,然后根据需要在RightsSet创建RightsSet记录。 当Entity中的Profil ... -
SQL 2005: WITH X AS ( SELECT id, min(value) as minval from Foo group by id ) SELECT * FROM ( SELECT Foo.*, RANK() OVER ( PARTITION by Foo.id order by Foo.hid, Foo.value ) as Rank FROM Foo JOIN X on Foo.id = X.id and Foo.value = X.minval ) tmp WHER ...
-
使用NPoco 3,您只能映射1个一对多或多对多关系。 示例必须存在的项目是Product类中的[NPoco.PrimaryKey(“ProductId”)]标记。 所以你这样做: string sql = "sql with product-categorie relation"; List
products = db.Fetch (x => x.Categories, sql); 要么 string sql = "sql with product-productVar ... -
你会加入。 如果您想在结果中使用A,那么: select a.*, b.*, c.*, d.* from a join b on b.id_a = a.id_a left join bc on bc.id_b = b.id_b -- bridge table b <-> c left join c on c.id_c = bc.id_c left join bd on bd.id_b = b.id_b -- bridge table b <-> d left join d on d.id_d = bd.id ...
-
jOOQ还没有开箱即用的这种POJO映射,但是你可以利用像ModelMapper这样的东西,它具有专门的jOOQ集成 ,可以在一定程度上适用于这些场景。 从本质上讲,ModelMapper挂钩到jOOQ的RecordMapper API。 更多细节在这里: http://www.jooq.org/doc/latest/manual/sql-execution/fetching/recordmapper/ http://www.jooq.org/doc/latest/manual/sql-execution/ ...