logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Domain.DLS - no description

Documentation

       Module DLS
        : sigend

       Domain-local Storage

       type'akey

       Type of a DLS key

       valnew_key : ?split_from_parent:('a->'a)->(unit->'a)->'akeynew_keyf returns a new key bound to initialiser f for accessing domain-local variables.

       If  split_from_parent  is  not provided, the value for a new domain will be computed on-demand by the new
       domain: the first get call will call the initializer f and store that value.

       Warning.  f may be called several times if another call to get occurs during initialization on  the  same
       domain.  Only  the  'first'  value computed will be used, the other now-useless values will be discarded.
       Your initialization function should support this situation, or contain logic  to  detect  this  case  and
       fail.

       If  split_from_parent  is provided, spawning a domain will derive the child value (for this key) from the
       parent value. This computation happens in the parent domain and it always happens, regardless of  whether
       the child domain will use it.  If the splitting function is expensive or requires child-side computation,
       consider using 'aLazy.tkey :

               letinit()=...letsplit_from_parentparent_value=...parent-sidecomputation...;lazy(...child-sidecomputation...)letkey=Domain.DLS.new_key~split_from_parentinitletget()=Lazy.force(Domain.DLS.getkey)

       In  this  case  a  part  of  the  computation  happens  on the child domain; in particular, it can access
       parent_value concurrently with the parent domain, which may require  explicit  synchronization  to  avoid
       data races.

       valget : 'akey->'agetk returns v if a value v is associated to the key k on the calling domain's domain-local state. Sets
       k 's value with its initialiser and returns it otherwise.

       valset : 'akey->'a->unitsetkv updates the calling domain's domain-local state to  associate  the  key  k  with  value  v  .  It
       overwrites any previous values associated to k , which cannot be restored later.

OCamldoc                                           2025-06-12                                     Domain.DLS(3o)

Module

       Module   Domain.DLS

Name

       Domain.DLS - no description

See Also