Skip to content

Extract shared threading (mutex/cond) wrappers out of pub/sub into a dedicated module #318

Description

Summary

The cross-platform threading primitives — the mutex_* and cond_* wrapper functions (pthread on POSIX, CRITICAL_SECTION / CONDITION_VARIABLE on Windows) — currently live in valkey_glide_pubsub_common.{c,h}, because pub/sub introduced them first.

They are now also used by the MONITOR client (valkey_glide_monitor_common.*), which #includes valkey_glide_pubsub_common.h solely to obtain a mutex/condition variable. This is an awkward coupling: MONITOR has nothing to do with pub/sub, yet it depends on the pub/sub module for generic threading utilities.

Proposal

Extract the threading wrappers into a dedicated, neutral module, e.g. valkey_glide_threading.{c,h}:

  • Move mutex_init, mutex_lock, mutex_unlock, mutex_destroy
  • Move cond_init, cond_wait, cond_timedwait, cond_signal, cond_destroy
  • Update valkey_glide_pubsub_common.* and valkey_glide_monitor_common.* to include the new header
  • Add the new source file to config.m4, Makefile.frag, and package.xml

Context

Raised in review of #309 (MONITOR command). Deferred from that PR to keep its scope focused; the reviewer (@currantw) agreed to track it separately.

#309 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions