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

Release the whole amount #25

Closed
Enchufa2 opened this Issue Dec 1, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@Enchufa2
Copy link
Member

Enchufa2 commented Dec 1, 2015

We should be able to do this:

t0 <- create_trajectory() %>%
  seize("dummy", 3) %>%
  timeout(1) %>%
  release("dummy") # releases 3

And, of course, this:

t0 <- create_trajectory() %>%
  seize("dummy", 3) %>%
  timeout(1) %>%
  release("dummy", 1) %>% # releases 1
  timeout(1) %>% 
  release("dummy") # releases 2

@Enchufa2 Enchufa2 added the enhancement label Dec 1, 2015

@Bart6114

This comment has been minimized.

Copy link
Member

Bart6114 commented Dec 1, 2015

+1

Simple shortcut off the top of my head; save the seized number as an attribute with an uncommon prefix. In the first example above set e.g. an attribute ___seized__dummy with value 3 (in the background of-course). This can then be easily retrieved to release the correct amount. This does however incur an overhead (if you want to increment the seized amount you have to pass the attributes to the R side). Depending on the overhead incurred by monitoring the seized amount (in this shortcut style or by a robust c++ implementation), maybe only allow this from a given monitoring level.

In terms of syntax, it might require a different command like release_all(resource). As seize(resource) defaults to an amount of 1 it isn't unlogical that release(resource) also defaults to an amount of 1.

@Enchufa2

This comment has been minimized.

Copy link
Member

Enchufa2 commented Dec 1, 2015

I have plans for this. 😉 It should be managed by the resource itself. So I think it is best to reimplement the resource's server as a map of arrivals.

@Bart6114

This comment has been minimized.

Copy link
Member

Bart6114 commented Dec 1, 2015

Any educated guesses on how this would impact the run-time of larger simulations?

@Enchufa2

This comment has been minimized.

Copy link
Member

Enchufa2 commented Dec 1, 2015

It should be minimal because a map is similar to a hash table. It will be even smaller when we use an unordered_map from Boost or C++11 (this is in the TODO list).

@Enchufa2 Enchufa2 added the wontfix label Dec 1, 2015

@Enchufa2 Enchufa2 closed this Dec 1, 2015

@Enchufa2

This comment has been minimized.

Copy link
Member

Enchufa2 commented May 8, 2017

This is a good time to reopen this, because the enhancements implemented in the last year provide the required infrastructure to address it trivially.

Instead of changing release("resource") and release_selected()'s default amount, one solution would be to create another couple of verbs, release_all("resource") and release_selected_all(). But maybe release_all() is more intuitive for releasing the whole amount in every resource seized, which would be a nice addition too. For instance:

traj <- trajectory() %>%
  seize("dummy1", 3) %>%
  seize("dummy2") %>%
  timeout(1) %>%
  release_all()

Feelings, @Bart6114?

@Enchufa2 Enchufa2 reopened this May 8, 2017

@Enchufa2 Enchufa2 removed the wontfix label May 8, 2017

@Enchufa2 Enchufa2 changed the title Release activity shouldn't need to specify the amount Release the whole amount May 8, 2017

@Enchufa2 Enchufa2 added this to the v3.7.0 milestone Nov 8, 2017

@Enchufa2 Enchufa2 modified the milestones: v3.7.0, v3.8.0 Dec 12, 2017

@Enchufa2 Enchufa2 removed this from the v3.8.0 milestone Mar 25, 2018

Enchufa2 added a commit that referenced this issue Nov 30, 2018

@Enchufa2 Enchufa2 closed this in 6e02a74 Dec 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment