Writing to timerfd

EB0

New Member
Joined
Jul 28, 2023
Messages
4
Reaction score
0
Credits
48
Hello. I recently asked the question on the SO, which, to the other users' opinion, can not be asked (and thus answered) in their Q&A platform. Here is the post text:

I use eventfd to pass events to the epoll. Now I need not only pass the "immediate" event using this mechanism, but also have delayed event. This is obviously timerfd. But can timerfd replace eventfd completely, and if I need immediate event while timer is not expired yet, I just write 64-bit word into its file descriptor to trigger event right now? I do not see this functionality in the man pages - only read is defined. The functionality would be very helpful! Why is it not there?

See here, and to my surprise there's nothing online about such way of using timerfd. Am I the first asking for it?

Edit: of course it is possible using timerfd_settime() setting period of 1 ns to have timer expiration, but something tells me the whole task will consume more resources and time than writing int64_t equal to 1 to the file handle.

Edit 2: with the discussion below I make a conclusion that eventfd can be discontinued and disarmed timerfd may be used in place of eventfd if write to its FD to raise the event is possible. Why NOT?

Hopefully anyone has an idea or history why timerfd can't be used like eventfd? Someone with knowledge of internals? Thanks!
 

Members online


Top