Skip to content
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

[Suggestions Requested] I need some suggestions about ITC framework #36

Open
imkiva opened this issue Mar 5, 2020 · 0 comments
Open
Assignees
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@imkiva
Copy link
Contributor

imkiva commented Mar 5, 2020

Recently I made a inter-thread event emitter based on the event_emitter_fast.
And I tested, feeling comfortable.

Please please please give me some advice!!

The modified event emitter for inter-thread communication purpose: Here

Usage:

void thread_run(handler *&H) {
    handler h;
    H = &h;
    h.on("key-enter", []() {
        printf("thread: Enter pressed\n");
    });
    h.on("key", [](int ch) {
        printf("thread: pressed %c\n", ch);
    });
    printf("MessageQueue started\n");
    h.loop();
    printf("MessageQueue exited\n");
}

int main() {
    handler *H = nullptr;
    std::thread thread(thread_run, std::ref(H));
    int ch = 0;
    while ((ch = getchar()) != 'q') {
        if (ch == '\n') {
            H->emit("key-enter");
        } else {
            H->emit("key", ch);
        }
    }
    H->quit();
    thread.join();
}

This would probably fix #33
Thanks!!!!!!!!!!!!!!!!!
@mikecovlee @shirakamiemmmer

@imkiva imkiva added help wanted Extra attention is needed question Further information is requested labels Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants