Skip to content

Reloading of nif modules #12

@tinglei8

Description

@tinglei8

After a nif module is reloaded, all the nif functions are overwritten by elixir placeholders.

defmodule test_nif do

  require Logger

  @on_load :init

  def init() do
    :erlang.load_nif("./priv/test_nif", 0)
    :ok
  end

  def test_a() do
    Logger.error "NIF library not loaded"
  end

end

After reloading test_a.beam, test_nif.test_a() will call the placeholder instead of nif functions.

One way I can think of to solve the glitch is to add an _on_reprise_reload() function to test_nif:

def _on_reprise_reload() do 
  init()
end

And have reprise call the function after reloading the module

But there might be better ways.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions