This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//js | |
$('.j-spoiler').each(function(){ | |
new Spoiler(this); | |
}); | |
Spoiler = function(container) { | |
this.container = $(container); | |
this.head = this.container.find('.j-spoiler-head'); | |
this.body = this.container.find('.j-spoiler-body'); | |
this.close = this.container.find('.j-spoiler-close'); | |
this.init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
from typing import List | |
class ReentrantRWLock: | |
""" | |
A lock object that allows many simultaneous "read locks", but only one "write lock." | |
it also ignores multiple write locks from the same thread | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" rwlock.py | |
A class to implement read-write locks on top of the standard threading | |
library. | |
This is implemented with two mutexes (threading.Lock instances) as per this | |
wikipedia pseudocode: | |
https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Using_two_mutexes |