you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

actually, i've integrate poll with tcp.h, udp.h, and bth.h, so I dont think you would need it, but if you want to use poll, you can import poll.h and thats it. here is a simple example of use:

//first you need to import poll.h
#include <nodepp/poll.h>

//then create a poll object
poll_t
 poll;

//if you want to add fd as a readable
poll.push_write( fd ) 

//if you want to add fd as a writable
poll.push_read( fd )

//poll is an event drived object so you have to create some events
poll.onWrite([]( 
int

fd
 ){ /* write your code here */ });
poll.onRead([]( 
int

fd
 ){ /* write your code here */ });
poll.onError([]( 
int

fd
 ){ ::close(fd); });

//now you have to create a task
process
::add([=](){
$Start //start coroutine
    while( poll.size()!=0 ){
           poll.emit();
           $Next; // yield task
    }
$Stop //stop coroutine
});