Comments (8)
Can I ask you to provide a reproducible example? Also, why do you use a check in the first case while you don't do that in the second case?
from uvw.
I can work on providing a full example sure.
As for the ErrorEvent/CheckEvent, I was just copying the examples from tests.
from uvw.
Here is full example with a chunk for uvw and a chunk for libuv.
I expect that the loop simply blocks until a SIGINT is captured.
#include <uvw.hpp>
#include <iostream>
#include <unistd.h>
void on_uv_walk(uv_handle_t* handle, void*)
{
std::cout << "on_uv_walk()\n";
uv_close(handle, NULL);
}
void on_sigint_received(uv_signal_t *handle, int)
{
std::cout << "on_sigint_received()\n";
int result = uv_loop_close(handle->loop);
if(result == UV_EBUSY)
{
uv_walk(handle->loop, on_uv_walk, NULL);
}
}
int main()
{
// ---------------------------------------------------------------
// uvw
// ---------------------------------------------------------------
// auto loop = uvw::Loop::getDefault();
// auto signal_ = loop->resource<uvw::SignalHandle>();
// signal_->on<uvw::ErrorEvent>(
// [](const uvw::ErrorEvent&, uvw::SignalHandle&)
// {
// std::cerr << "uvw::ErrorEvent()\n";
// });
// signal_->on<uvw::CheckEvent>(
// [&](const uvw::CheckEvent&, uvw::SignalHandle&)
// {
// std::cout << "uvw::CheckEvent()\n";
// loop->stop();
// });
// if(signal_->init())
// {
// std::cout << "signal - initialized?\n";
// signal_->start(2);
// }
// else
// {
// std::cerr << "signal - error?\n";
// }
// std::cout << "start\n";
// loop->run();
// std::cout << "stop\n";
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// libuv
// ---------------------------------------------------------------
uv_signal_t *sigint = new uv_signal_t;
uv_signal_init(uv_default_loop(), sigint);
uv_signal_start(sigint, on_sigint_received, SIGINT);
uv_loop_t* main_loop = uv_default_loop();
std::cout << "start\n";
uv_run(main_loop, UV_RUN_DEFAULT);
std::cout << "stop\n";
// ---------------------------------------------------------------
return 0;
}
from uvw.
I can work on providing a full example sure. As for the ErrorEvent/CheckEvent, I was just copying the examples from tests.
Disregard this, I see what you are asking now.
I'm not sure where I saw the return code being checked on init()
for uvw but I'm sure I just copied it.
I didn't use it for libuv as I was just quickly testing for comparison purposes.
from uvw.
No, I mean, you have a check handle in one case while you don't have it in the other case.
It's like comparing apples and pears, you know. That is why I'm not fully getting what you're doing here.
Also, with libuv
you're attaching a listener for a sigint while you aren't doing the same when using uvw
.
So, it's quite obvious that the two examples work differently maybe?
from uvw.
I'll just rephrase.
Can you point me to an example of how to capture a SIGINT with a listener?
Thanks.
from uvw.
I'm afraid I can't. If there isn't one in the testsuite, then I can't really help.
from uvw.
Something has clearly been lost in translation here,
I was able to solve the problem on my own switching CheckEvent
to SignalEvent
.
This will capture the SIGINT and run my callback.
This behaviour is not in the test suite which lead to my confusion as the test suite only uses CheckEvent
.
from uvw.
Related Issues (20)
- ErrorCode EPIPE -4047 Broken Pipe HOT 2
- Error in .vtu Files with hexahedron type of elements HOT 1
- loop::run not marked inline HOT 1
- 48 error HOT 1
- Vcpkg uvw version 2.12.1 HOT 1
- Is there 2.x backward compatibility layer? HOT 15
- uvw_fs_event and uvw_loop fail on Darwin PPC HOT 5
- create v2 branch for bug fixes HOT 4
- Provide a way to specify buffer size HOT 5
- How to Handle a Broken Pipe (SIGPIPE) in UVW? HOT 2
- Segmentation fault on calling thread.join due to destructor also calling thread.join HOT 5
- Q: cpp http server based on libuv HOT 3
- suppress compiler warning HOT 8
- Build issues HOT 5
- Document suggested cleanup approach HOT 9
- Error when building on Windows - multiple rules generate _deps/libuv-build/uv.lib HOT 4
- Issuing multiple filesystem operations at a time with user supplied buffer HOT 2
- Question: Pipe process output HOT 1
- uvw_net available HOT 8
- Run a task on next event loop iteration HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uvw.