Skip to content

Commit

Permalink
Comment out triggering diamond detection in parents
Browse files Browse the repository at this point in the history
  • Loading branch information
FelonEkonom committed Nov 21, 2024
1 parent a58b363 commit 5a76b10
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 77 deletions.
18 changes: 9 additions & 9 deletions lib/membrane/core/bin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,15 @@ defmodule Membrane.Core.Bin do
{:noreply, state}
end

defp do_handle_info(Message.new(:start_diamond_detection), state) do
:ok = Parent.DiamondDetectionController.start_diamond_detection(state)
{:noreply, state}
end

defp do_handle_info(Message.new(:trigger_diamond_detection), state) do
:ok = __MODULE__.DiamondDetectionController.trigger_diamond_detection(state)
{:noreply, state}
end
# defp do_handle_info(Message.new(:start_diamond_detection), state) do
# :ok = Parent.DiamondDetectionController.start_diamond_detection(state)
# {:noreply, state}
# end

# defp do_handle_info(Message.new(:trigger_diamond_detection), state) do
# :ok = __MODULE__.DiamondDetectionController.trigger_diamond_detection(state)
# {:noreply, state}
# end

defp do_handle_info(Message.new(:child_death, [name, reason]), state) do
case Parent.ChildLifeController.handle_child_death(name, reason, state) do
Expand Down
18 changes: 9 additions & 9 deletions lib/membrane/core/bin/diamond_detection_controller.ex
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
defmodule Membrane.Core.Bin.DiamondDetectionController do
@moduledoc false
# defmodule Membrane.Core.Bin.DiamondDetectionController do
# @moduledoc false

require Membrane.Core.Message, as: Message
# require Membrane.Core.Message, as: Message

alias Membrane.Core.Bin.State
# alias Membrane.Core.Bin.State

@spec trigger_diamond_detection(State.t()) :: :ok
def trigger_diamond_detection(state) do
Message.send(state.parent_pid, :trigger_diamond_detection)
end
end
# @spec trigger_diamond_detection(State.t()) :: :ok
# def trigger_diamond_detection(state) do
# Message.send(state.parent_pid, :trigger_diamond_detection)
# end
# end
24 changes: 11 additions & 13 deletions lib/membrane/core/parent/child_life_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ defmodule Membrane.Core.Parent.ChildLifeController do
"""
@spec handle_spec(ChildrenSpec.t(), Parent.state()) :: Parent.state() | no_return()
def handle_spec(spec, state) do



spec_ref = make_ref()
canonical_spec = make_canonical(spec)

Expand Down Expand Up @@ -165,22 +162,23 @@ defmodule Membrane.Core.Parent.ChildLifeController do
dependent_specs: dependent_specs,
awaiting_responses: MapSet.new()
})
|> trigger_diamond_detection()

# |> trigger_diamond_detection()

state = StartupUtils.exec_handle_spec_started(all_children_names, state)
proceed_spec_startup(spec_ref, state)
end

defp trigger_diamond_detection(state) do
cond do
Component.bin?(state) ->
:ok = Bin.DiamondDetectionController.trigger_diamond_detection(state)
state
# defp trigger_diamond_detection(state) do
# cond do
# Component.bin?(state) ->
# :ok = Bin.DiamondDetectionController.trigger_diamond_detection(state)
# state

Component.pipeline?(state) ->
Pipeline.DiamondDetectionController.trigger_diamond_detection(state)
end
end
# Component.pipeline?(state) ->
# Pipeline.DiamondDetectionController.trigger_diamond_detection(state)
# end
# end

defp assert_all_static_pads_linked_in_spec!(children_definitions, links) do
pads_to_link =
Expand Down
24 changes: 12 additions & 12 deletions lib/membrane/core/parent/diamond_detection_controller.ex
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
defmodule Membrane.Core.Parent.DiamondDetectionController do
@moduledoc false
# defmodule Membrane.Core.Parent.DiamondDetectionController do
# @moduledoc false

require Membrane.Core.Message, as: Message
# require Membrane.Core.Message, as: Message

alias Membrane.Core.Parent
# alias Membrane.Core.Parent

@spec start_diamond_detection(Parent.state()) :: :ok
def start_diamond_detection(state) do
state.children
|> Enum.each(fn {_child, %{pid: child_pid}} ->
Message.send(child_pid, :start_diamond_detection)
end)
end
end
# @spec start_diamond_detection(Parent.state()) :: :ok
# def start_diamond_detection(state) do
# state.children
# |> Enum.each(fn {_child, %{pid: child_pid}} ->
# Message.send(child_pid, :start_diamond_detection)
# end)
# end
# end
18 changes: 9 additions & 9 deletions lib/membrane/core/pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ defmodule Membrane.Core.Pipeline do
{:noreply, state}
end

defp do_handle_info(Message.new(:start_diamond_detection), state) do
state = __MODULE__.DiamondDetectionController.start_diamond_detection(state)
{:noreply, state}
end

defp do_handle_info(Message.new(:trigger_diamond_detection), state) do
state = __MODULE__.DiamondDetectionController.trigger_diamond_detection(state)
{:noreply, state}
end
# defp do_handle_info(Message.new(:start_diamond_detection), state) do
# state = __MODULE__.DiamondDetectionController.start_diamond_detection(state)
# {:noreply, state}
# end

# defp do_handle_info(Message.new(:trigger_diamond_detection), state) do
# state = __MODULE__.DiamondDetectionController.trigger_diamond_detection(state)
# {:noreply, state}
# end

defp do_handle_info(Message.new(:initialized, child), state) do
state = ChildLifeController.handle_child_initialized(child, state)
Expand Down
42 changes: 21 additions & 21 deletions lib/membrane/core/pipeline/diamond_detection_controller.ex
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
defmodule Membrane.Core.Pipeline.DiamondDetectionController do
@moduledoc false
# defmodule Membrane.Core.Pipeline.DiamondDetectionController do
# @moduledoc false

require Membrane.Core.Message, as: Message
# require Membrane.Core.Message, as: Message

alias Membrane.Core.Parent
alias Membrane.Core.Pipeline.State
# alias Membrane.Core.Parent
# alias Membrane.Core.Pipeline.State

@spec trigger_diamond_detection(State.t()) :: State.t()
def trigger_diamond_detection(%State{} = state) when state.diamond_detection_triggered? do
state
end
# @spec trigger_diamond_detection(State.t()) :: State.t()
# def trigger_diamond_detection(%State{} = state) when state.diamond_detection_triggered? do
# state
# end

def trigger_diamond_detection(%State{} = state) do
message = Message.new(:start_diamond_detection)
send_after_timeout = Membrane.Time.second() |> Membrane.Time.as_milliseconds(:round)
self() |> Process.send_after(message, send_after_timeout)
# def trigger_diamond_detection(%State{} = state) do
# message = Message.new(:start_diamond_detection)
# send_after_timeout = Membrane.Time.second() |> Membrane.Time.as_milliseconds(:round)
# self() |> Process.send_after(message, send_after_timeout)

%{state | diamond_detection_triggered?: true}
end
# %{state | diamond_detection_triggered?: true}
# end

@spec start_diamond_detection(State.t()) :: State.t()
def start_diamond_detection(%State{} = state) do
:ok = Parent.DiamondDetectionController.start_diamond_detection(state)
%{state | diamond_detection_triggered?: false}
end
end
# @spec start_diamond_detection(State.t()) :: State.t()
# def start_diamond_detection(%State{} = state) do
# :ok = Parent.DiamondDetectionController.start_diamond_detection(state)
# %{state | diamond_detection_triggered?: false}
# end
# end
8 changes: 4 additions & 4 deletions lib/membrane/core/pipeline/state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ defmodule Membrane.Core.Pipeline.State do
setup_incomplete?: boolean(),
stalker: Membrane.Core.Stalker.t(),
subprocess_supervisor: pid(),
awaiting_setup_completition?: boolean(),
diamond_detection_triggered?: boolean()
awaiting_setup_completition?: boolean()
# diamond_detection_triggered?: boolean()
}

# READ THIS BEFORE ADDING NEW FIELD!!!
Expand All @@ -59,7 +59,7 @@ defmodule Membrane.Core.Pipeline.State do
stalker: nil,
resource_guard: nil,
subprocess_supervisor: nil,
awaiting_setup_completition?: false,
diamond_detection_triggered?: false
awaiting_setup_completition?: false

# diamond_detection_triggered?: false
end

0 comments on commit 5a76b10

Please sign in to comment.