markusthoemmes commented on a change in pull request #3656: Adjust the 
ForcibleSemaphore mechanism 
URL: 
https://github.com/apache/incubator-openwhisk/pull/3656#discussion_r206109998
 
 

 ##########
 File path: common/scala/src/main/scala/whisk/common/ForcableSemaphore.scala
 ##########
 @@ -121,4 +139,11 @@ class ForcableSemaphore(maxAllowed: Int) {
 
   /** Returns the number of currently available permits. Possibly negative. */
   def availablePermits: Int = sync.permits
+
+  /** Set the new maxAllowed value. */
+  def setMaxAllowed(newMaxAllowed: Int): Unit = {
 
 Review comment:
   Do we need to synchronize here? Especially since `forceChangeState` and 
resetting maxAllowed are non-atomic operations.
   
   Can we reuse bits from here: 
http://blog.teamlazerbeez.com/2009/04/20/javas-semaphore-resizing/?
   
   I guess your `forceChangeState` method is roughly the same as 
`reducePermits` in the original `Semaphore` impl. modulo you calculate an 
absolute number whereas they pass in a difference, so that should be fine.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to