Skip to content

Instantly share code, notes, and snippets.

@schoentoon
schoentoon / inotify.c
Last active February 27, 2024 22:13
Simple example of how to use inotify with libevent. Compile with gcc -o inotify inotify.c -levent
#include <stdio.h>
#include <event.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/inotify.h>
static void displayInotifyEvent(struct inotify_event *i)
{
printf(" wd =%2d; ", i->wd);
@ricardobeat
ricardobeat / semaphore.js
Created March 3, 2011 01:30
simple semaphore for parallel async execution, with error handling.
function queue(name){
queue.q[name]++ || (queue.q[name] = 1);
return function(err){
if (err && queue.e[name]) queue.e[name](err);
else if (err) throw err;
process.nextTick(function(){
queue.q[name]--;
queue.check(name);
});
}