<commit_before>General Computing Node
======================

`gen_node` is a concept code for a generic computing node server implemented in Erlang. It is based on a modified version of Joe Armstrong's Universal Server. It uses a `gen_server` behavior to wrap around its functionality.

Summary
=======

User of `gen_node` application can spawn any number of gen_node servers. By default, these processes will wait and do nothing. Once they get instructions on what to do, they'll "become" what they are told.

Compile and Run
===============

````
make
_rel/gen_node_release/bin/gen_node_release console
````

Example
=======

````
1> Double = fun Double() -> receive {_, reset} -> ok; {From, Args} -> From ! Args+Args, Double() end end.
#Fun<erl_eval.44.106461118>
2> Square = fun Square() -> receive {_, reset} -> ok; {From, Args} -> From ! Args*Args, Square() end end.
#Fun<erl_eval.44.106461118>
3> {ok, N, _} = gen_node:start_server().
{ok,<0.42.0>,#Ref<0.0.0.45>}
4> gen_node:become(N, Double).
ok
5> gen_node:send(N, 16).
ok
6> flush().
Shell got 32
ok<commit_msg>update readme with more details about implementation<commit_after>General Computing Node
======================

`gen_node` is a concept code for a generic computing node server implemented in Erlang. It is based on a modified version of Joe Armstrong's Universal Server.

Summary
=======

User of `gen_node` application can spawn any number of gen_node servers. By default, these processes will wait and do nothing. Once they get instructions on what to do, they'll "become" what they are told.

Internal Implementation
=======================

Each `gen_node` server is implemented as a process pair.

The first process - the controlling process - is a `gen_server` under the control of the OTP supervisor. This process' main task is to keep track of the status of the "node". It's also used as a gateway for sending the task to the actual worker process.

The second process is the worker process that performs actual tasks and computations. It's linked to the controlling process. Its sole task is to wait for the instructions from the controlling process and perform the task given.

Compile and Run
===============

````
make
_rel/gen_node_release/bin/gen_node_release console
````

Example
=======

````
1> Double = fun Double() -> receive {_, reset} -> ok; {From, Args} -> From ! Args+Args, Double() end end.
#Fun<erl_eval.44.106461118>
2> Square = fun Square() -> receive {_, reset} -> ok; {From, Args} -> From ! Args*Args, Square() end end.
#Fun<erl_eval.44.106461118>
3> {ok, N, _} = gen_node:start_server().
{ok,<0.42.0>,#Ref<0.0.0.45>}
4> gen_node:become(N, Double).
ok
5> gen_node:send(N, 16).
ok
6> flush().
Shell got 32
ok
{'fraction_non_alphanumeric': 0.14902250092216895, 'fraction_numerical': 0.030247141276281815, 'mean_word_length': 4.661795407098121, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3032040', 'n_tokens_mistral': 876, 'n_tokens_neox': 809, 'n_words': 348}