Go to: Control Panel\Hardware and Sound\Power Options\Edit Plan Settings (it may also be called Change plan settings) (you can alternatively just search for “Edit power plan” in the windows search bar)
Click “change advanced power settings”
Go to “Sleep->Allow wake timers” and change the setting to Disable.
%% do_purge(Module) %% Kill all processes running code from *old* Module, and then purge the %% module. Return true if any processes killed, else false.
do_purge(Mod0) -> Mod = to_atom(Mod0), case erlang:check_old_code(Mod) of false -> false; true -> do_purge(processes(), Mod, false) end.
%% do_soft_purge(Module) %% Purge old code only if no procs remain that run old code. %% Return true in that case, false if procs remain (in this %% case old code is not purged)
do_soft_purge(Mod) -> case erlang:check_old_code(Mod) of false -> true; true -> do_soft_purge(processes(), Mod) end.
%% @doc Return a list of beam modules that have changed. all_changed() -> [M || {M, Fn} <- code:all_loaded(), is_list(Fn), is_changed(M)].
%% @spec is_changed(atom()) -> boolean() %% @doc true if the loaded module is a beam with a vsn attribute %% and does not match the on-disk beam file, returns false otherwise. is_changed(M) -> try module_vsn(M:module_info()) =/= module_vsn(code:get_object_code(M)) catch _:_ -> false end.
With the GLOBAL keyword, the statement applies globally for all subsequent sessions. Existing sessions are unaffected.
With the SESSION keyword, the statement applies to all subsequent transactions performed within the current session.
Without any SESSION or GLOBAL keyword, the statement applies to the next (not started) transaction performed within the current session. Subsequent transactions revert to using the SESSION isolation level.
在事务内部无法修改下一个事务的隔离级别:
1 2 3 4 5 6 7 8
mysql> begin; Query OK, 0 rows affected (0.00 sec) mysql> set transaction isolation level serializable; ERROR 1568 (25001): Transaction isolation level can't be changed while a transaction is in progress mysql> commit; Query OK, 0 rows affected (0.00 sec) mysql> set transaction isolation level serializable; Query OK, 0 rows affected (0.00 sec)
或者
1 2 3 4
set tx_isolation = 'read-uncommitted'; set tx_isolation = 'read-committed'; set tx_isolation = 'repeatable-read'; set tx_isolation = 'serializable';
there also exists {allocate_zero, Ny, Ng} - Ny Y registers
label {label, N}
Nth label in the module
function {function, Name, Arity, LabelID}
defines a function
bif {bif, FuncAtom, {f, 0}, [], {x, 0}}
gc_bif {gc_bif, '*', {f, A}, N1, [R1, R2, R3]}
jumps to a function named '*'
multiply R1 and R2, and set the result into R3. If any failure occurs jump to A. If GC is triggered include N1 X registers starting at X0 in the root set for GC.
send send.
sends the data in X0 ?
loop_rec {loop_rec, {f, N}, {x, 0}}
receive clause starts here, till loop_rec_end
wait_timeout {wait_timeout, {f, N}, {integer, T}}
test {test, is_eq_exact, {f, N}, [{x,0}, {atom, foo}]}
> receive > Pattern1 [when Guard1] -> > Expressions1; > Pattern2 [when Guard2] -> > Expressions2; > ... > after > Time -> > ExpressionsTimeout > end >
When we enter a receive statement, we start a timer (but only if an after section is present in the expression).
Take the first message in the mailbox and try to match it against Pattern1, Pattern2, and so on. If the match succeeds, the message is removed from the mailbox, and the expressions following the pattern are evaluated.
If none of the patterns in the receive statement matches the first message in the mailbox, then the first message is removed from the mailbox and put into a “save queue.” The second message in the mailbox is then tried. This procedure is repeated until a matching message is found or until all the messages in the mailbox have been examined.
If none of the messages in the mailbox matches, then the process is suspended and will be rescheduled for execution the next time a new message is put in the mailbox. Note that when a new message arrives, the messages in the save queue are not rematched; only the new message is matched.
As soon as a message has been matched, then all messages that have been put into the save queue are reentered into the mailbox in the order in which they arrived at the process. If a timer was set, it is cleared.
If the timer elapses when we are waiting for a message, then evaluate the expressions ExpressionsTimeout and put any saved messages back into the mailbox in the order in which they arrived at the process.
loop() -> receive {smoke, Smoker, AvailableMaterials} -> Smoker ! smoke, receive doneSmoke -> loop() end end
以及:
1 2 3 4 5 6 7 8 9 10 11 12 13
loop() -> receive {high_prio, Msg} -> process_high; after0 -> receive {low_prio, Msg} -> process_low; _ -> ok end end, loop()
串联的receive:
1 2 3 4 5 6
receive foo -> ok end, receive bar -> ok end
验证
启动一个分布式节点,方便通过远程shell连过来。
1 2
(foo@deng)1> erlang:register(shell,self()). true
向shell进程发消息,并进入匹配。
1 2 3 4 5 6 7 8 9
(foo@deng)2> self() ! c, self() ! d, self() ! a. a (foo@deng)3> process_info(self(),messages). {messages,[c,d,a]} (foo@deng)4> receive a -> ok end. ok (foo@deng)5> process_info(self(),messages). {messages,[c,d]} (foo@deng)6> receive a -> ok end.
Each process has its own input queue for messages it receives. New messages received are put at the end of the queue. When a process executes a receive, the first message in the queue is matched against the first pattern in the receive. If this matches, the message is removed from the queue and the actions corresponding to the pattern are executed.
However, if the first pattern does not match, the second pattern is tested. If this matches, the message is removed from the queue and the actions corresponding to the second pattern are executed. If the second pattern does not match, the third is tried and so on until there are no more patterns to test. If there are no more patterns to test, the first message is kept in the queue and the second message is tried instead. If this matches any pattern, the appropriate actions are executed and the second message is removed from the queue (keeping the first message and any other messages in the queue). If the second message does not match, the third message is tried, and so on, until the end of the queue is reached. If the end of the queue is reached, the process blocks (stops execution) and waits until a new message is received and this procedure is repeated.
The Erlang implementation is “clever” and minimizes the number of times each message is tested against the patterns in each receive.
we know that none of the messages that exist in the message queue before the call to make_ref/0 can be matched out in the receive statement. Therefore we can avoid going through the entire message queue if we introduce two new instructions (here written as BIFs in pseudo-Erlang):
The recv_mark/1 instruction will save the current position and SomeUniqInteger in the process context. The recv_set instruction will verify that SomeUniqInteger is still stored in the process context. If it is, it will set the current pointer for the message queue (the next message to be read out) to the position that was saved by recv_mark/1.
The remove_message instruction must be modified to invalidate the information stored by the previous recv_mark/1, in case there is another receive executed between the calls to recv_mark/1 and recv_set/1.
We use a reference to a label (i.e. a position in the loaded code) as the SomeUniqInteger.
typedef struct{ ErlMessage* first; ErlMessage** last; /* point to the last next pointer */ ErlMessage** save; Sint len; /* queue length */ /* * The following two fields are used by the recv_mark/1 and * recv_set/1 instructions. */ BeamInstr* mark; /* address to rec_loop/2 instruction */ ErlMessage** saved_last; /* saved last pointer */ }