![]() |
Helixis 1.0
Task Programming API
|
#include <iostream> #include "hlx/core.h" HLX_SIMPLE_TASK(task1) { char key; HLX_TASK_BEGIN(); while (1) { HLX_CHAN_READ(hlx_hash("KeyPress"), &key, char); std::cout << "Key : " << key << std::endl; } HLX_TASK_END(); } HLX_SIMPLE_TASK(task2) { HLX_TASK_BEGIN(); while (1) { HLX_CHAN_WRITE(hlx_hash("KeyPress"), getchar(), char); } HLX_TASK_END(); } int main() { hlx_get_api_entries()->malloc_entry = &malloc; hlx_get_api_entries()->free_entry = &free; if (hlx_core_init() < 1) return (EXIT_FAILURE); hlx_chan_create(hlx_hash("KeyPress")); hlx_core_add_task(task1, 0); hlx_core_add_task(task2, 0); hlx_core_start(); hlx_core_destroy(); return (EXIT_SUCCESS); }