-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4243 from esl/log-helper-parallel
Prepare log_helper for parallel tests
- Loading branch information
Showing
3 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
%% Helper module for an ETS table with an owner process | ||
|
||
-module(ets_helper). | ||
|
||
-compile([export_all, nowarn_export_all]). | ||
|
||
%% API | ||
|
||
new(Name) -> | ||
new(Name, []). | ||
|
||
new(Name, ExtraOpts) -> | ||
TabOwner = spawn(?MODULE, init_tab, [self(), Name, ExtraOpts]), | ||
receive | ||
table_created -> ok | ||
after | ||
5000 -> | ||
exit(TabOwner, kill), | ||
error("Table owner did not respond") | ||
end. | ||
|
||
delete(Name) -> | ||
TabOwner = ets:info(Name, owner), | ||
ets:delete(Name), | ||
TabOwner ! stop, | ||
ok. | ||
|
||
%% Helpers | ||
|
||
init_tab(Caller, Name, ExtraOpts) -> | ||
ets:new(Name, [named_table, public | ExtraOpts]), | ||
Caller ! table_created, | ||
receive stop -> ok end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters