Skip to content

Commit

Permalink
refactor put_int_nonblocking
Browse files Browse the repository at this point in the history
refactor put_int_nonblocking 2
  • Loading branch information
Edison-CBS committed Feb 8, 2024
1 parent a7dfc08 commit dc4c63f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions common/params_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from libcpp cimport bool
from libcpp.string cimport string
from libcpp.vector cimport vector
import threading

cdef extern from "common/params.h":
cpdef enum ParamKeyType:
Expand All @@ -23,6 +22,7 @@ cdef extern from "common/params.h":
int put(string, string) nogil
void putNonBlocking(string, string) nogil
void putBoolNonBlocking(string, bool) nogil
void putIntNonBlocking(string, int) nogil
int putBool(string, bool) nogil
int putInt(string, int) nogil
bool checkKey(string) nogil
Expand Down Expand Up @@ -120,6 +120,11 @@ cdef class Params:
with nogil:
self.p.putBoolNonBlocking(k, val)

def put_int_nonblocking(self, key, int val):
cdef string k = self.check_key(key)
with nogil:
self.p.putIntNonBlocking(k, val)

def remove(self, key):
cdef string k = self.check_key(key)
with nogil:
Expand All @@ -131,6 +136,3 @@ cdef class Params:

def all_keys(self):
return self.p.allKeys()

def put_int_nonblocking(key, int val, d=""):
threading.Thread(target=lambda: Params(d).put_int(key, val)).start()

0 comments on commit dc4c63f

Please sign in to comment.