gijsbers / go-pcre Goto Github PK
View Code? Open in Web Editor NEWThis project forked from glenn-brown/golang-pkg-pcre
Perl Compatible Regular Expression shim for Go
License: Other
This project forked from glenn-brown/golang-pkg-pcre
Perl Compatible Regular Expression shim for Go
License: Other
pcrejit requires a separate thread specific stack. This leads to some very weird issues when using this library with multiple threads. I naively called CompileJIT in one part of the program and then used it in other parts without realizing that per thread stacks were required. This isn't featured in the documentation, nor is there a way to handle it in the current Go API.
http://www.pcre.org/original/doc/html/pcrejit.html#SEC9
http://www.pcre.org/original/doc/html/pcreapi.html#SEC8
package main
import (
"log"
pcre "github.com/gijsbers/go-pcre"
)
func findIndex(a pcre.Regexp) {
for {
// Compile a new function with JIT. Since this is running in a goroutine and
// probably a different thread the JIT stack will be violated.
b := pcre.MustCompileJIT("[^\\/><\\s]+", 0, 0)
if b.FindIndex([]byte(" <p>"), 0) == nil {
log.Fatal("b.FindIndex(...) should never equal nil")
}
if a.FindIndex([]byte(" <p>"), 0) == nil {
log.Fatal("a.FindIndex(...) should never equal nil")
}
}
}
func main() {
a := pcre.MustCompileJIT("[^\\/><\\s]+", 0, 0)
for i := 0; i < 4; i++ {
go findIndex(a)
}
findIndex(a)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.