Skip to content

Commit 7a44188

Browse files
authored
feat: Mutex を定義 (#49)
* feat: `Mutex` クラスを定義 * chore: テストを追加
1 parent ec4c4ab commit 7a44188

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

core/mutex.rbs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Mutex
2+
def initialize: () -> void
3+
4+
def lock: () -> self
5+
6+
def unlock: () -> self
7+
8+
def try_lock: () -> bool
9+
10+
def locked?: () -> bool
11+
12+
def owned?: () -> bool
13+
end

test/mutex.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
mutex = Mutex.new
4+
5+
mutex.lock
6+
7+
mutex.unlock
8+
9+
mutex.try_lock
10+
11+
mutex.locked?
12+
13+
mutex.owned?

0 commit comments

Comments
 (0)