void testlockpoolstress() { std::list<std::future<void> > futures; typedef LIBCXX_NAMESPACE::sharedpool<> pool_t; pool_t pool=pool_t::create(); for (size_t i=0; i<2; i++) { futures.push_back (std::async (std::launch::async, [i, &pool] { for (size_t j=0; j<50; ++j) { auto w=pool->addLockSet(pool_t::base::uniquelock, LIBCXX_NAMESPACE::eventfd::create()); while (!w->locked()) w->getNotifyEvent()->event(); } })); } for (size_t i=0; i<10; i++) { futures.push_back (std::async (std::launch::async, [i, &pool] { for (size_t j=0; j<50; ++j) { auto w=pool->addLockSet(pool_t::base::sharedlock, LIBCXX_NAMESPACE::eventfd::create()); while (!w->locked()) w->getNotifyEvent()->event(); } })); } while (!futures.empty()) { futures.front().get(); futures.pop_front(); } }
void doIt () { int rc; // puts("Initializing inotify ..."); // puts("Waiting for events ..."); // Call to inotify_init // puts("Getting inotify fd (via inotify_init) ..."); int fd; fd = inotify_init(); if (fd == -1) { perror("inotify_init()"); } else { // Watch a folder const char* PATH = "/tmp/downloads"; int wd = inotify_add_watch(fd, PATH, IN_ATTRIB | IN_CREATE); if (wd == -1) { perror("inotify_add_watch()"); } else { printf("Waiting on something to happen ..."); struct inotify_event* ev = getNotifyEvent(fd); // Print out what happened printf("%d %d %d %d %s\n", ev->wd, ev->mask, ev->cookie, ev->len, ev->name); puts("(whoa.)"); free(ev); // Close up shop // puts("Closing inotify fd (w close())"); rc = inotify_rm_watch(fd, wd); if (rc == -1) { perror("inotify_rm_watch()"); } } rc = close(fd); if (rc == -1) { perror("close()"); } } // puts("Done."); }