在Poco :: ClassLoader中,AbstractMetaObject是否没有同步问题?

问题描述

我发现AbstractMetaObject :: autoDelete(pObject)调用不是线程安全的,它访问一组拥有的对象。似乎从线程访问MetaObject可能会导致拥有的对象集崩溃。

这是一个问题-为什么我们不能在不赋予MeataObject所有权的情况下删除对象?

显示我们现在删除对象的方式的代码段:

    // ClassLoader instance,imagine it is passed from somewhere to the working thread
    Poco::ClassLoader<IProtocol> protocol_loader;
    
    // load library,call to prevent library unload from other threads
    protocol_loader.loadLibrary(plugin_lib);
    // construct an object
    IProtocol* proto = protocol_loader.create(protocol_class_name);

    // work with the object
    proto->DoGreateThings();

    // give ownership to the MetaObject of object Class
    // !!! autoDelete is not thread-safe but should be colled to force object destroy !!!
    proto = protocol_loader.classFor(protocol_class_name).autoDelete(proto);
    // do not wait library is unloaded,force object deletion
    protocol_loader.destroy(protocol_class_name,proto);

    // create other objects from the same lib
    // ....

    // unload library if not used on other threads
    protocol_loader.unloadLibrary(plugin_lib);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...