yruslan / channel_scala

Scala implementation of the concurrency primitive similar to GoLang channels.
Apache License 2.0
8 stars 0 forks source link

Implement an extended semaphore #14

Closed yruslan closed 1 year ago

yruslan commented 1 year ago

Background

Classic semaphore uses 2 methods:

While a semaphore provides good means of controlling shared resource usage, issues like 'the dining philosophers problem' can arise when a thread needs to consume more than one resource to function.

Feature

Create an extended semaphore that provides

This can only work if waiting threads wait for resources in FIFO order. Otherwise, threads that require only 1 resource will take precedence and can create liveness issues for threads that require more than 1.

yruslan commented 1 year ago

Standard Java semaphores support this it seems.