Skip to content

Situation shared_ptr in embedded systems #116

@jplcz

Description

@jplcz

I have created Proof of Concept inside https://github.com/jplcz/smart_ptr/pull/1/files

General idea is to allow "nothrow" allocation of shared_ptr class of objects from smart_ptr library, however without need to go through expensive exception handling code, which can be ofter either disabled or it's usage available only in certain scopes (e.g. kernel mode code).
In such cases, developers may want to simply handle errors instead of crashing entire thread.

I have also added BOOST_SP_EMBEDDED ifdefs, which allow developer to disable any APIs which may throw. Currently it requires using sp_nothrow_tag to constructors. Plain functions get try prefix, such as try_make_unique or try_make_shared. If anything fails, they simply return empty smart pointer. Another method is reset, which now becomes try_reset - instead of leaving object in "partial" state, it doesn't modify the object if memory allocated would fail.

Are there any plans to introduce such feature in the library ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions