一个简单的锁库 Keyway

码农软件 · 软件分类 · 其他开发相关 · 2019-10-21 14:44:28

软件介绍

A simple lock file library.

Features
  • Provides mutual exclusion for scripts that require the same resource.

  • Requires three additional lines of code in your script, including sourcing the library.

  • Scripts using Keyway can be configured to either terminate or busy-wait if a resource is blocked.

  • Keyway will report when an external error was caught and there are lock files in the lock directory.

Usage:
  • acquire_lock_for "your_task_name"

    • If the resource is not locked, your task will execute, otherwise it will terminate.

  • acquire_spinlock_for "your_task_name"

    • If the resource is locked, your task will wait until the lock has been released before acquiring its own lock and executing.

Return Code Explanations:
  1. Your application was not able to acquire lock.

  2. There was some other problem:

  • Keyway could not create the lock directory.

  • Keyway could not create or remove a lock.

  • An error was caught and there are lock files in the lock directory.

  • An example:
    #!/bin/bash
    source keyway_lib.sh
    
    # optionally override the lock file directory
    LOCK_DIR="alt-lock-dir"
    
    # attempt to lock the shared resource
    acquire_lock_for "your_task_name"
    
    # if the lock was successful, execute the task
    echo "executing critical section"
    
    # release the lock when the task is done
    release_lock_for "your_task_name"

    GPRS_core_structure.png

    本文地址:https://codercto.com/soft/d/17247.html

    Effective JavaScript

    Effective JavaScript

    赫尔曼 (David Herman) / 黄博文、喻杨 / 机械工业出版社 / 2014-1-1 / CNY 49.00

    Effective 系列丛书经典著作,亚马逊五星级畅销书,Ecma 的JavaScript 标准化委员会著名专家撰写,JavaScript 语言之父、Mozilla CTO —— Brendan Eich 作序鼎力推荐!作者凭借多年标准化委员会工作和实践经验,深刻辨析JavaScript 的内部运作机制、特性、陷阱和编程最佳实践,将它们高度浓缩为极具实践指导意义的 68 条精华建议。 本书共......一起来看看 《Effective JavaScript》 这本书的介绍吧!

    SHA 加密
    SHA 加密

    SHA 加密工具

    正则表达式在线测试
    正则表达式在线测试

    正则表达式在线测试

    RGB HSV 转换
    RGB HSV 转换

    RGB HSV 互转工具