Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "move" operation #84

Closed
samoht opened this issue Oct 17, 2014 · 2 comments
Closed

Add a "move" operation #84

samoht opened this issue Oct 17, 2014 · 2 comments
Labels
area/api Related to any API
Milestone

Comments

@samoht
Copy link
Member

samoht commented Oct 17, 2014

No description provided.

@samoht samoht added the type/bug Related to a bug label Dec 15, 2014
@samoht
Copy link
Member Author

samoht commented Dec 15, 2014

This is needed by most filesystem-like protocol to ensure atomicity.

@samoht samoht modified the milestone: 1.0.0 Jan 5, 2015
@samoht samoht added enhancement area/api Related to any API and removed type/bug Related to a bug design labels Feb 4, 2015
@dsheets dsheets mentioned this issue Jul 12, 2015
@samoht
Copy link
Member Author

samoht commented Feb 15, 2017

It is now easy to define move with 1.0:

let move t ~info src dst = 
  S.with_tree t ~info [] (fun tree ->
    S.Tree.find_tree tree src >>= fun v ->
    S.Tree.remove tree src >>= fun tree ->
    S.Tree.add_tree tree dst v
  )

Byt default with_tree will use the Test_and_set strategy, e.g. this will ensure that the move is done atomically. It is possible to define a more fined-grained scope for the transaction by using the longest common prefix between src and dst instead of [] to avoid live-locks.

@samoht samoht closed this as completed Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Related to any API
Projects
None yet
Development

No branches or pull requests

1 participant