Skip to content

Instantly share code, notes, and snippets.

View knawrocke's full-sized avatar

Kelly Nawrocke knawrocke

  • Datameer, Inc.
  • SLC
View GitHub Profile
@eatonphil
eatonphil / psql-srv.py
Last active April 28, 2024 09:26 — forked from matteobertozzi/psql-srv.py
postgres "server" wire protocol example (ported python3)
# th30z@u1310:[Desktop]$ psql -h localhost -p 55432
# Password:
# psql (9.1.10, server 0.0.0)
# WARNING: psql version 9.1, server version 0.0.
# Some psql features might not work.
# Type "help" for help.
#
# th30z=> select foo;
# a | b
# ---+---

Synchronizing a Pool of Resources

Here are several approaches for synchronization around a pool of limited resources that are checked in and out by a gang of threads.

Pools

There are three different pools: MonitorPool which uses monitor.rb, MutexCondvarPool which uses a Mutex and a ConditionVariable, and SemaphorePool which uses a java.util.concurrent.Semaphore (only under JRuby).

Request