-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add Runtime::Stop API #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,58 @@ | ||
| # Copyright (c) 2025-present Samsung Electronics Co., Ltd | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| Name: lwnode-embedding | ||
| Summary: - | ||
| Version: 1.0.0 | ||
| Release: 1 | ||
| Group: Development | ||
| License: Apache-2.0 and MIT and BSD-2-Clause and BSD-3-Clause and BOEHM-GC and ICU and LGPL-2.1+ and Zlib | ||
| Source: %{name}-%{version}.tar.gz | ||
|
|
||
| BuildRequires: cmake | ||
| BuildRequires: make | ||
| BuildRequires: pkgconfig(dlog) | ||
|
|
||
|
|
||
| # Initialize the variables | ||
| %define _output_path out/tizen/arm/Release | ||
|
|
||
| %description | ||
| lwnode embedding test | ||
|
|
||
| %prep | ||
| %setup -q | ||
|
|
||
| %build | ||
|
|
||
| cmake -S test/embedding -B%{_output_path} -DCMAKE_BUILD_TYPE=Release | ||
| make -C %{_output_path} -j$(nproc) | ||
|
|
||
|
|
||
| %install | ||
|
|
||
| %clean | ||
| rm -fr ./*.list | ||
| rm -fr ./*.manifest | ||
|
|
||
| %post | ||
| /sbin/ldconfig | ||
|
|
||
| %postun | ||
| /sbin/ldconfig | ||
|
|
||
| %files | ||
| %defattr(-,tizenglobalapp,root,-) | ||
|
|
||
| %license LICENSE LICENSE.Apache-2.0 LICENSE.NodeJS LICENSE.MIT LICENSE.BSD-2-Clause LICENSE.BSD-3-Clause LICENSE.BOEHM-GC LICENSE.ICU LICENSE.LGPL-2.1+ LICENSE.Zlib |
This file contains hidden or 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,39 @@ | ||
| #include <filesystem> | ||
| #include <future> | ||
| #include <iostream> | ||
| #include <thread> | ||
| #include <chrono> | ||
|
|
||
| #include <lwnode-public.h> | ||
| #include <message-port.h> | ||
|
|
||
| #define COUNT_OF(array) (sizeof(array) / sizeof((array)[0])) | ||
|
|
||
| int main(int argc, char* argv[]) { | ||
| auto runtime = std::make_shared<lwnode::Runtime>(); | ||
|
|
||
| std::promise<void> promise; | ||
| std::future<void> init_future = promise.get_future(); | ||
| const char* script = "test/embedding/test-20-runtime-stop.js"; | ||
| std::string path = (std::filesystem::current_path() / script).string(); | ||
| char* args[] = {const_cast<char*>(""), const_cast<char*>(path.c_str())}; | ||
|
|
||
| std::thread worker = std::thread( | ||
| [&](std::promise<void>&& promise) mutable { | ||
| // FIXME: Fix Runtime::Init() call to ensure environment initialization | ||
| // before running the loop, Runtime::Run(). This workaround passes a | ||
| // promise directly to know when that is. | ||
| runtime->Start(COUNT_OF(args), args, std::move(promise)); | ||
| }, | ||
| std::move(promise)); | ||
|
|
||
| init_future.wait(); | ||
|
|
||
| std::cout << "[C]sleep app" << std::endl; | ||
| std::this_thread::sleep_for(std::chrono::seconds(3)); | ||
| runtime->Stop(); | ||
| std::cout << "[C]terminate app" << std::endl; | ||
|
|
||
| worker.join(); | ||
| return 0; | ||
| } |
This file contains hidden or 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,19 @@ | ||
| const lwnode = process.lwnode; | ||
| const http = require('http'); | ||
|
|
||
| if (process.lwnode.hasSystemInfo('tizen')) { | ||
| console.log('[JS] start gmain-loop') | ||
| require("./gmain-loop").init(); | ||
| } | ||
|
|
||
| console.log('[JS] start app') | ||
|
|
||
| console.log('[JS] create server') | ||
| const server = http.createServer(); | ||
| server.listen(1234); | ||
|
|
||
| lwnode.ref(); | ||
|
|
||
| setInterval(() => { | ||
| console.log('[JS]loop'); | ||
| }, 1000); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd like to suggest to avoid
youin API documentation. It's better to use a more neutral and objective phrasing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I will fix next commit.